代码
Private Sub Form_Load()
PictureZoom.Picture = Picture1.Picture
PictureZoom.Width = Picture1.Width
PictureZoom.Height = Picture1.Height
HScroll5.Value = 4
HScroll5_Change
End Sub
Private Sub HScroll1_Change()
PictureZoom.Left = -HScroll1
End Sub
Private Sub HScroll1_Scroll()
PictureZoom.Left = -HScroll1
End Sub
Private Sub HScroll5_Change()
PictureZoom.Cls
PictureZoom.Width = (Picture1.Width * HScroll5.Value / 4) + 25
PictureZoom.Height = (Picture1.Height * HScroll5.Value / 4) + 25
PictureZoom.PaintPicture Picture1.Picture, 0, 0, Picture1.Width * HScroll5.Value / 4, Picture1.Height * HScroll5.Value / 4, 0, 0, Picture1.Width, Picture1.Height
HScroll1.Max = PictureZoom.Width - Picture5.Width
VScroll1.Max = PictureZoom.Height - Picture5.Height
Call AdjustTopLeft
Text1.Text = "Zoom " & HScroll5.Value / 4 * 100 & "%"
End Sub
Private Sub VScroll1_Change()
PictureZoom.Top = -VScroll1
End Sub
Private Sub VScroll1_Scroll()
PictureZoom.Top = -VScroll1
End Sub
Private Sub AdjustTopLeft()
If PictureZoom.Width < Picture5.Width Then
PictureZoom.Left = (Picture5.Width - PictureZoom.Width) / 2
HScroll1.Visible = False
Else
PictureZoom.Left = 0
HScroll1.Visible = True
End If
If PictureZoom.Height < Picture5.Height Then
PictureZoom.Top = (Picture5.Height - PictureZoom.Height) / 2
VScroll1.Visible = False
Else
PictureZoom.Top = 0
VScroll1.Visible = True
End If
End Sub