Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SCROLL BARS

Posted on 1998-11-27
3
Medium Priority
?
150 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 280 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses

618 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