我的代码,供参考:
Public Sub ReSize()
HScroll1.Max = Image1.Width - Picture1.ScaleWidth
If Image1.Width < Picture1.ScaleWidth Then
HScroll1.Visible = False
Image1.Left = (Picture1.ScaleWidth - Image1.Width) / 2
Else
HScroll1.Visible = True
Image1.Left = Picture1.ScaleLeft
End If
VScroll1.Max = Image1.Height - Picture1.ScaleHeight
If Image1.Height < Picture1.ScaleHeight Then
VScroll1.Visible = False
Image1.Top = (Picture1.ScaleHeight - Image1.Height) / 2
Else
VScroll1.Visible = True
Image1.Top = Picture1.ScaleTop
End If
End Sub
Private Sub Form_Load()
Image1.Picture = LoadPicture(App.Path & "\地图.jpg")
ReSize
End Sub
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Static Cx As Long
Static Cy As Long
Cx = Image1.Width
Cy = Image1.Height
Select Case Button.Key
Case "Open"
Case "Save"
Case "Delete"
Case "Print"
Case "Magnify"
Image1.Width = Cx * 1.25
Image1.Height = Cy * 1.25
ReSize
If Image1.Width > 32767 Or Image1.Height > 32767 Then Toolbar1.Buttons(7).Enabled = False
If Image1.Width > 5000 And Image1.Height > 5000 Then Toolbar1.Buttons(8).Enabled = True
Case "Reduce"
Image1.Width = 0.8 * Cx
Image1.Height = 0.8 * Cy
ReSize
If Image1.Width < 5000 Or Image1.Height < 5000 Then Toolbar1.Buttons(8).Enabled = False
If Image1.Width < 32767 And Image1.Height < 32767 Then Toolbar1.Buttons(7).Enabled = True
End Select
End Sub
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub
PictureBox做容器,Image放在PictureBox里面
[[it] 本帖最后由 超级隐士 于 2008-5-21 11:42 编辑 [/it]]