新建From1(窗体),新建Picture1到2(PictureBox,其中Picture2是画在Picture1中),HScroll1(HScrollBar),VScroll1(VScrollBar)代码:
Private Sub Form_Load()
Picture2.AutoSize = True
Picture2.Left = 0
Picture2.Top = 0
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
VScroll1.Min = 0
HScroll1.Min = 0
HScroll1.Min = 0
VScroll1.Max = Picture2.Height - Picture1.Height
HScroll1.Max = Picture2.Width - Picture1.Width
If HScroll1.Max < 0 Then HScroll1.Enabled = False
If VScroll1.Max < 0 Then VScroll1.Enabled = False
Picture2.Picture = LoadPicture(App.Path & "\manongku.jpg")
VScroll1.Min = 0
HScroll1.Min = 0
VScroll1.Max = Picture2.Height - Picture1.Height
HScroll1.Max = Picture2.Width - Picture1.Width
If HScroll1.Max < 0 Then HScroll1.Enabled = False
If VScroll1.Max < 0 Then VScroll1.Enabled = False
End Sub
Private Sub HScroll1_change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_change()
Picture2.Top = -VScroll1.Value
End Sub
记得准备一张manongku.jpg在当前目录哦。