I'd just like to post this in case it helps anyone. Found this on microsoft's website and it did just about what I wanted bar a couple of small modifications other forum members have helped me make.
It attaches horizontal and vertical scrollsbars to the sides of a picturebox (picture1) if the picturebox is larger than the form or when the form is resized to a size smaller than the picturebox. Suggestions for adding wheelmouse scrolldown would be very welcome.
1. Start a new project in Visual Basic.
2. Add a horizontal scroll bar control and a vertical scroll bar control to Form1. (The size doesn't matter because the program automatically sizes the scroll bars in the Form Resize event code.)
3. Add a picture box control to Form1.
4. Add the following code to the Form
VB Code:
Sub Form_Resize() On Error Resume Next ' Position the scroll bars: HScroll1.Left = 0 VScroll1.Top = 0 If Picture1.Width > ScaleWidth Then HScroll1.Top = ScaleHeight - HScroll1.Height Else HScroll1.Top = ScaleHeight End If If Picture1.Height > HScroll1.Top Then VScroll1.Left = ScaleWidth - VScroll1.Width If Picture1.Width > VScroll1.Left Then HScroll1.Top = ScaleHeight - HScroll1.Height End If Else VScroll1.Left = ScaleWidth End If HScroll1.Width = ScaleWidth If HScroll1.Top > 0 Then VScroll1.Height = HScroll1.Top ' Set the scroll bar ranges HScroll1.Max = Picture1.Width - VScroll1.Left VScroll1.Max = Picture1.Height - HScroll1.Top HScroll1.SmallChange = Picture1.Width / 10 HScroll1.LargeChange = Picture1.Width - HScroll1.Max VScroll1.SmallChange = Picture1.Height / 10 VScroll1.LargeChange = Picture1.Height - VScroll1.Max HScroll1.ZOrder 0 VScroll1.ZOrder 0 End Sub Sub HScroll1_Change() Picture1.Left = -HScroll1.Value End Sub Sub VScroll1_Change() Picture1.Top = -VScroll1.Value End Sub Private Sub HScroll1_GotFocus() Picture1.SetFocus End Sub Private Sub VScroll1_GotFocus() Picture1.SetFocus End Sub


Reply With Quote