ID: 257
Viewed: 3104
Added: Jul 26, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
Add a picture box and what ever you want in the box. then add vert. and horz. scrollbars and a button just wide enough for the scroll bars. then insert this code to make it scroll the length of the box.
Highlight all by clicking in box
<!---Declaration--->
Option Explicit
' size of scrollbars in twips
Const SB_WIDTH = 300 ' width of vertical scrollbars
Const SB_HEIGHT = 300 ' height of horizontal scrollbars
'--------------------------------------------
' code for handling form resizing and scrolling
'--------------------------------------------
Highlight All
<!---Code--->
Private Sub Form_Resize()
' resize the scrollbars along the form
HScroll1.Move 0, ScaleHeight - SB_HEIGHT, ScaleWidth - SB_WIDTH
VScroll1.Move ScaleWidth - SB_WIDTH, 0, SB_WIDTH, ScaleHeight - SB_HEIGHT
cmdFiller.Move ScaleWidth - SB_WIDTH, ScaleHeight - SB_HEIGHT, SB_WIDTH, SB_HEIGHT
' put these controls on top
HScroll1.ZOrder
VScroll1.ZOrder
cmdFiller.ZOrder
picCanvas.BorderStyle = 0
' a click on the arrow moves one pixel
HScroll1.SmallChange = ScaleX(10, vbPixels, vbTwips)
VScroll1.SmallChange = ScaleY(10, vbPixels, vbTwips)
'a click on the scrollbar move 16 pixels
HScroll1.LargeChange = HScroll1.SmallChange * 32
VScroll1.LargeChange = VScroll1.SmallChange * 32
' if the form is larger than the picCanvas picture box
' we don't need to show the scrollbar
If ScaleWidth < picCanvas.Width + SB_WIDTH Then
HScroll1.Visible = True
HScroll1.Max = picCanvas.Width + SB_WIDTH - ScaleWidth
Else
HScroll1.Value = 0
HScroll1.Visible = False
End If
If ScaleHeight < picCanvas.Height + SB_HEIGHT Then
VScroll1.Visible = True
VScroll1.Max = picCanvas.Height + SB_HEIGHT - ScaleHeight
Else
VScroll1.Value = 0
VScroll1.Visible = False
End If
cmdFiller.Visible = (HScroll1.Visible Or VScroll1.Visible)
MoveCanvas
End Sub
Private Sub HScroll1_Change()
MoveCanvas
End Sub
Private Sub HScroll1_Scroll()
MoveCanvas
End Sub
Private Sub VScroll1_Change()
MoveCanvas
End Sub
Private Sub VScroll1_Scroll()
MoveCanvas
End Sub
Sub MoveCanvas()
picCanvas.Move -HScroll1.Value, -VScroll1.Value
End Sub
;
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.