Solved

SCROLL BARS

Posted on 1998-11-27
3
145 Views
Last Modified: 2012-05-04
Hello experts!
Is it possible to make a form scrollable. If so, how do I do it?
0
Comment
Question by:soft4u
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
trillo earned 70 total points
ID: 1447088
Your answer is in the next code, the scrollbar will appear when there are controls outside the client area, anyway I can tell you that this code is useless as when you click on the scrollbars nothing will happen because in the VB environment the Forms don't have a "scroll" event.


Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_HSCROLL = &H100000
Private Const WS_VSCROLL = &H200000
Dim prev As Long

Private Sub Form_Load()
Dim l As Long
l = GetWindowLong(Me.hwnd, GWL_STYLE)
prev = SetWindowLong(Me.hwnd, GWL_STYLE, l Or WS_VSCROLL)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(Me.hwnd, GWL_STYLE, prev)
End Sub
---------------------------
The correct way would be placing a vertical and a horizontal scrollbar on your form, moving and resizing them when the form rezises, and of course moving all your controls int he scroll event of the scrollbars. This is obviously more work but it's the only way in VB.

Trillo
0
 

Author Comment

by:soft4u
ID: 1447089
Tanks for the info. but is there any way to increase the height of a form to make it like two screens high and scroll back and forth. I am making a checklist in my form and the info on this cannot be viewed on the screen.
0
 
LVL 2

Expert Comment

by:trillo
ID: 1447090
The only way would be placing scrollbar at the right side (for example) of your form. In the form's Resize event you resize the scrollbar to fit the form's height.
When the user presses the scrollbar you should move all your controls up or down. (You could use the "For Each..." syntax to implement this in a few lilnes), you should, of course, need to use negative coordinates.
If you, for example, move all your controls 50 pixels upwards, the uppermost controls won't be visible (they will be virtually above the screen, with negative coordinates).

Tell me what you think
Trillo
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

914 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

21 Experts available now in Live!

Get 1:1 Help Now