Solved

Scrolling Forms

Posted on 1998-06-09
5
172 Views
Last Modified: 2010-05-03
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.
0
Comment
Question by:BWATERS
5 Comments
 
LVL 9

Expert Comment

by:Dalin
Comment Utility
BWATERS,
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


0
 
LVL 7

Expert Comment

by:kamall
Comment Utility
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.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
The question/answer Dalin refers to is:
http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10056205
(and it does work, I tested it myself)
0
 
LVL 2

Accepted Solution

by:
DanAvni earned 50 total points
Comment Utility
Hi,

Look at this site it has complete code on how to make scrollable forms.

http://www.cobb.com/ivb/9705/ivb9756.htm
0
 

Author Comment

by:BWATERS
Comment Utility
Sorry for the delay getting back to you...had to implement it first.  Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now