Solved

SCROLL BARS

Posted on 1998-11-27
3
146 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

808 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