Solved

Scrolling Forms

Posted on 1998-06-09
5
174 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
ID: 1462962
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
ID: 1462963
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
ID: 1462964
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
ID: 1462965
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
ID: 1462966
Sorry for the delay getting back to you...had to implement it first.  Thanks!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
VB6 Compile Compatibility Issue 4 102
Adding to a VBA? 6 70
Modifying Conditional Format from VBA code 3 57
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

809 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