BWATERS
asked on
Scrolling Forms
How would one create a 'scrolling form?' For example, if the Form.Height is greater than the Screen.Height...how (in VB5) would the user be able to get to the bottom (or top)...thanks.
BWATERS,
You can find the solution in the VB Knowledge Base. I don't remember the article number, but give the keyword "scroll" in the search.
You can find the solution in the VB Knowledge Base. I don't remember the article number, but give the keyword "scroll" in the search.
The question/answer Dalin refers to is:
https://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10056205
(and it does work, I tested it myself)
https://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10056205
(and it does work, I tested it myself)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay getting back to you...had to implement it first. Thanks!
Here is the answer that clifABB give in a earlier question.
I think it is the right answer.
If this works, you can ask clifABB to lock in this question
Regards
Dalin
P.S. clif's answer:
What you want to do is place a picturebox on your form. Size it to the maximum size you will need. Set the BorderStyle property to
False. Move all the controls that are on the form (except the picturebox, of course) to the picturebox.
Now, add a scrollbar to the form and align it next to the picturebox.
In the form's resize event, place this code:
Private Sub Form_Resize()
VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight
VScroll1.Max = Picture1.Height - Me.ScaleHeight
If VScroll1.Max < 0 Then
VScroll1.Max = 0
End If
VScroll1.LargeChange = Me.ScaleHeight
VScroll1.SmallChange = Me.ScaleHeight / 10
End Sub
In the scrollbar's change event, place this code:
Private Sub VScroll1_Change()
Picture1.Top = VScroll1.Value * -1
End Sub
Note: The above code will work for vertical only (which is what you requested). To add horizontal scrolling, add a horizontal scrollbar to the
form.
Add the following code to the form load event:
Private Sub Form_Resize()
VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight - HScroll1.Height
VScroll1.Max = Picture1.Height - Me.ScaleHeight
If VScroll1.Max < 0 Then
VScroll1.Max = 0
End If
VScroll1.LargeChange = Me.ScaleHeight
VScroll1.SmallChange = Me.ScaleHeight / 10
HScroll1.Move 0, Me.ScaleHeight - HScroll1.Height, Me.ScaleWidth - VScroll1.Width, HScroll1.Height
HScroll1.Max = Picture1.Width - Me.ScaleWidth
If HScroll1.Max < 0 Then
HScroll1.Max = 0
End If
HScroll1.LargeChange = Me.ScaleWidth
HScroll1.SmallChange = Me.ScaleWidth / 10
End Sub
Add the following code to the vertical scrollbar change event:
Private Sub VScroll1_Change()
Picture1.Top = VScroll1.Value * -1
End Sub
Add the following code to the horizontal scrollbar change event:
Private Sub HScroll1_Change()
Picture1.Left = HScroll1.Value * -1
End Sub