Solved

Scrolling Forms

Posted on 1998-06-09
5
176 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

860 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