'初始化 Private Sub Form_Load() VScroll1.Max = Image1.Height - Picture1.Height HScroll1.Max = Image1.Width - Picture1.Width End Sub '横向滚动 Private Sub HScroll1_Change() Image1.Left = -HScroll1.Value End Sub '纵向滚动 Private Sub VScroll1_Change() Image1.Top = -VScroll1.Value End Sub
先取得图像的大小,再用SetHorizontalExtent和SetVerticalExtent来设置
滚动。
Private Sub Form_Load()
VScroll1.Max = Image1.Height - Picture1.Height
HScroll1.Max = Image1.Width - Picture1.Width
End Sub
'横向滚动
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
'纵向滚动
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub