Solved

SCROLL BARS

Posted on 1998-11-27
3
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

717 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