| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2071 人关注过本帖
标题:[求助]如何让 图片框 出现滚动条啊
只看楼主 加入收藏
NSGSF
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-3-9
结帖率:100%
收藏
 问题点数:0 回复次数:6 
[求助]如何让 图片框 出现滚动条啊
如何让图片框出现滚动条啊 图片总是显示不全 但又不希望让它Autosize
搜索更多相关主题的帖子: 滚动 
2007-03-21 21:03
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
使用HScrollBar,VScrollBar组合.

我的msn: myfend@
2007-03-21 21:05
NSGSF
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-3-9
收藏
得分:0 
谢谢 能具体点吗 呵呵
2007-03-21 21:29
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 
用Image控件,将其属性Stretch 设置为TRUE就可以了

Image和picture控件好像没有设置滚动条的属性

雁无留踪之意,水无取影之心
2007-03-21 21:56
NSGSF
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-3-9
收藏
得分:0 
回复:(NSGSF)[求助]如何让 图片框 出现滚动条啊

7Xx7svbv.rar (2.47 KB) [求助]如何让 图片框 出现滚动条啊


哈哈 自己研究出来啦 大家测试一下

2007-03-21 23:53
NSGSF
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-3-9
收藏
得分:0 
突然发现 以上程序有缺陷 当调整其中一个滚动条后 在调整另一个时 图片会先恢复到初始位置
希望大家能帮忙改正 我也会努力克服的
2007-03-22 00:58
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 

偶现在用的也是关于图片超长窗体,楼主可试试下面方法:
先在窗体上拖一个双屏幕长的frame1框(你的图片可以在这上面拖出),高18000;宽15085;(窗体的属性Scalemode取1-Twip)
然后拖水平与垂直的两个滚动条;(注意:要在窗体上拖出)
Vscrloo1(竖滚动条)属性:LargeChange=20000,Max=11055
HScroll1(横)属性:LargeChange=8000;Max=1000;Top=18000;Width=14040
上面是偶的选用参数,你也可自选;
建立一个模块:下面代码放进去
Option Explicit
Public Type POINTL
x As Long
y As Long
End Type
Declare Function CallWindowProc _
Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Declare Function SetWindowLong _
Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Declare Function ScreenToClient Lib "user32" _
(ByVal hwnd As Long, xyPoint As POINTL) As Long
Public Const GWL_WNDPROC = -4
Public Const SPI_GETWHEELSCROLLLINES = 104
Public Const WM_MOUSEWHEEL = &H20A
Public WHEEL_SCROLL_LINES As Long
Global lpPrevWndProc As Long
Public Sub Hook(ByVal hwnd As Long)
lpPrevWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
Call SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, WHEEL_SCROLL_LINES, 0)
If WHEEL_SCROLL_LINES > Form1.VScroll1.Max Then
WHEEL_SCROLL_LINES = Form1.VScroll1.Max
End If
End Sub
Public Sub UnHook(ByVal hwnd As Long)
Dim lngReturnValue As Long
lngReturnValue = SetWindowLong(hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Function WindowProc(ByVal hw As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim pt As POINTL
Select Case uMsg
Case WM_MOUSEWHEEL
If wParam = -7864320 Then
If Form1.VScroll1.Value <= Form1.VScroll1.Max - 300 Then '4个300值可调鼠标滚轮移动屏幕的速度,可取300-1000(值越大,移动速度越快)
Form1.VScroll1.Value = Form1.VScroll1.Value + 300
Else
Form1.VScroll1.Value = Form1.VScroll1.Max
End If
ElseIf wParam = 7864320 Then
If Form1.VScroll1.Value >= 300 Then
Form1.VScroll1.Value = Form1.VScroll1.Value - 300
Else
Form1.VScroll1.Value = 0
End If
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Select
End Function

Public Function HIWORD(LongIn As Long) As Integer
HIWORD = (LongIn And &HFFFF0000) \ &H10000
End Function
Public Function LOWORD(LongIn As Long) As Integer
LOWORD = LongIn And &HFFFF&
End Function

下面代码放在窗体中:
Private Sub Form_Load()
Hook Me.hwnd
End Sub
Private Sub Form_Resize()
If Frame1.Height > Me.Height Then
VScroll1.Visible = True
Else
VScroll1.Visible = False
End If
If Frame1.Width > Me.Width Then
HScroll1.Visible = True
Else
HScroll1.Visible = False
End If
HScroll1.Left = 0
HScroll1.Top = Me.ScaleHeight - HScroll1.Height
VScroll1.Left = Me.ScaleWidth - VScroll1.Width
VScroll1.Top = 0
HScroll1.Width = Me.ScaleWidth
VScroll1.Height = Me.ScaleHeight
If VScroll1.Visible = True Then
If HScroll1.Visible = True Then
HScroll1.Width = Abs(Me.ScaleWidth - VScroll1.Width)
VScroll1.Height = Abs(Me.ScaleHeight - HScroll1.Height)
End If
End If
HScroll1.Max = (Frame1.Width - Me.Width) + 3 * VScroll1.Width
VScroll1.Max = (Frame1.Height - Me.Height) + 3 * HScroll1.Height
HScroll1.ZOrder
VScroll1.ZOrder
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHook Me.hwnd
End Sub
Private Sub HScroll1_Change()
Frame1.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Frame1.Top = -VScroll1.Value
End Sub
Private Sub VScroll1_GotFocus() '此段可防止滚动条闪烁,借用一个按钮控件
Command1.SetFocus
End Sub

2007-03-22 14:48
快速回复:[求助]如何让 图片框 出现滚动条啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035252 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved