Solved

SCROLL BARS

Posted on 1998-11-27
3
144 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

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

6 Experts available now in Live!

Get 1:1 Help Now