Dim oldx As Single
Dim oldy As Single
Dim newx As Single
Dim newy As Single
Dim move As Boolean
Private Sub Form_Load()
pictureim.Picture = LoadPicture("c:\windows\安装程序.bmp")
End Sub
Private Sub Form_Resize()
On Error Resume Next
Picturerp.Width = Form1.ScaleWidth - VScroll1.Width
Picturerp.Height = Form1.ScaleHeight - HScroll1.Height
HScroll1.Width = Picturerp.Width
HScroll1.Top = Picturerp.Height
VScroll1.Height = Picturerp.Height
VScroll1.Left = Form1.ScaleWidth - VScroll1.Width
End Sub
Private Sub Pictureim_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
move = True
oldx = X
oldy = Y
End Sub
Private Sub Pictureim_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Dim movex As Single
Dim movey As Single
newx = X
newy = Y
If move Then '是否可移动
movex = newx - oldx '水平移动量
movey = newy - oldy '垂直移动量
If pictureim.Top >= 0 Then '是否下移到极限
pictureim.Top = 0
If newy >= oldy Then '是否继续下移
oldy = newy
movey = 0
End If
End If
If pictureim.Top <= Picturerp.Height - pictureim.Height Then
pictureim.Top = Picturerp.Height - pictureim.Height
If newy <= oldy Then
movey = 0
End If
End If
pictureim.Top = pictureim.Top + movey
VScroll1.Value = pictureim.Top / (Picturerp.Height - _
pictureim.Height) * 100
If pictureim.Left >= 0 Then
pictureim.Left = 0
If newx >= oldy Then
oldx = newx
monex = 0
End If
End If
If pictureim.Left <= Picturerp.Width - pictureim.Width Then
pictureim.Left = Picturerp.Width - pictureim.Width
If newx <= oldy Then
oldy = newy
movey = 0
End If
End If
HScroll1.Value = pictureim.Left / (Picturerp.Width - _
pictureim.Width) * 100
pictureim.Left = pictureim.Left + movex
End If
End Sub
Private Sub pictureim_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
move = False
End Sub
水平移动有些抖动,还请别人指点!