Private Sub Form_Load() Form1.ScaleMode = vbPixels '设置scalemode以像素为单位 Picture1.ScaleMode = vbPixels '将autosize设置为true,以picture2的边界扩展到实际的位图大小 Picture2.AutoSize = True '将每个图片框的borderstyle的属性设置为none Picture1.BorderStyle = 1 Picture2.BorderStyle = 0 '加载位图 Picture2.Picture = LoadPicture("C:\Documents and Settings\zhang\My Documents\My Pictures\无标题.bmp") '以下两句初始化两个图片框的位置 Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, ScaleHeight - HScroll1.Height Picture2.Move 0, 0 '将水平动条定位 HScroll1.Top = Picture1.Height HScroll1.Left = 0 HScroll1.Width = Picture1.Width '将垂直动条定位 VScroll1.Top = 0 VScroll1.Left = Picture1.Height VScroll1.Height = Picture1.Height '设置动条的MAX的属性 HScroll1.Max = Picture2.Width - Picture1.Width VScroll1.Max = Picture2.Height - Picture1.Height '判断子图片框是否将屏幕充满,若是,则无需使用动条 VScroll1.Visible = (Picture1.Height < Picture2.Height) HScroll1.Visible = (Picture1.Width < Picture2.Width) End Sub
Private Sub HScroll1_Change() Picture2.Left = -HScroll1.Value End Sub
Private Sub VScroll1_Change() Picture2.Top = -VScroll1.Value End Sub 运行不了?