Solved

Scroll Bars Component for Visual Basic

Posted on 2002-07-07
4
205 Views
Last Modified: 2013-11-25
Where Cand I download an VB Component to control my Form scroll bars??
I don't want to programme all the lines to adapt my form to the scroll bars that come in visual basic. I want a componet that does this automatically...
does it exists???

THANKS
0
Comment
Question by:mltolun
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 7138363
If I understand you correctly, you want a form that has a scrollable display area.  I have not seen such a form, but creating a control for it is relatively simple.

To do this, simply add a picturebox (named picScrollPanel, borderless) into the form, add horizontal and vertical scroll bars (named scrHorizontal and scrVertical, tabstop property=false) on the bottom and right, then add a textbox (named txtHideCorner, frameless, background=buttonface, text blank) to the lower right corner to hide that spot.

In your form's resize procedure:

Private Sub Form_Resize()
  scrHorizontal.Move 0, Me.ScaleHeight - scrHorizontal.Height, Me.ScaleWidth - scrVertical.Width
  scrVertical.Move Me.ScaleWidth - scrVertical.Width, 0, scrVertical.Width, Me.ScaleHeight - scrHorizontal.Height
  txtHideSpot.Move scrVertical.Left, scrHorizontal.Top, scrVertical.Width, scrHorizontal.Height
  picScrollWindow.Move 0, 0, 'scrVertical.Left, scrHorizontal.Top' no need to resize the picturebox or the scrolling effect won't work!
 
  ' Set scroll bar max
  lScrollMax = Me.ScaleWidth - picScrollWindow.Width
  If lScrollMax <= 0 Then
    scrHorizontal.Max = -lScrollMax
  Else
    scrHorizontal.Max = scrHorizontal.Min
  End If
 
  lScrollMax = Me.ScaleHeight - picScrollWindow.Height
  If lScrollMax <= 0 Then
    scrVertical.Max = -lScrollMax
  Else
    scrVertical.Max = scrVertical.Min
  End If
End Sub

At design time, place all controls into the picturebox, as large as you'd like.

Then add the following code to make the scrolling work:

Private Sub scrHorizontal_Change()
  picScrollWindow.Left = -scrHorizontal.Value
End Sub

Private Sub scrHorizontal_Scroll()
  scrHorizontal_Change
End Sub

Private Sub scrVertical_Change()
  picScrollWindow.Top = -scrVertical.Value
End Sub

Private Sub scrVertical_Scroll()
  scrVertical_Change
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7138376
If I understand you correctly, you want a form that has a scrollable display area.  I have not seen such a form, but creating a control for it is relatively simple.

To do this, simply add a picturebox (named picScrollPanel, borderless) into the form, add horizontal and vertical scroll bars (named scrHorizontal and scrVertical, tabstop property=false) on the bottom and right, then add a textbox (named txtHideCorner, frameless, background=buttonface, text blank) to the lower right corner to hide that spot.

In your form's resize procedure:

Private Sub Form_Resize()
  scrHorizontal.Move 0, Me.ScaleHeight - scrHorizontal.Height, Me.ScaleWidth - scrVertical.Width
  scrVertical.Move Me.ScaleWidth - scrVertical.Width, 0, scrVertical.Width, Me.ScaleHeight - scrHorizontal.Height
  txtHideSpot.Move scrVertical.Left, scrHorizontal.Top, scrVertical.Width, scrHorizontal.Height
  picScrollWindow.Move 0, 0, 'scrVertical.Left, scrHorizontal.Top' no need to resize the picturebox or the scrolling effect won't work!
 
  ' Set scroll bar max
  lScrollMax = Me.ScaleWidth - picScrollWindow.Width
  If lScrollMax <= 0 Then
    scrHorizontal.Max = -lScrollMax
  Else
    scrHorizontal.Max = scrHorizontal.Min
  End If
 
  lScrollMax = Me.ScaleHeight - picScrollWindow.Height
  If lScrollMax <= 0 Then
    scrVertical.Max = -lScrollMax
  Else
    scrVertical.Max = scrVertical.Min
  End If
End Sub

At design time, place all controls into the picturebox, as large as you'd like.

Then add the following code to make the scrolling work:

Private Sub scrHorizontal_Change()
  picScrollWindow.Left = -scrHorizontal.Value
End Sub

Private Sub scrHorizontal_Scroll()
  scrHorizontal_Change
End Sub

Private Sub scrVertical_Change()
  picScrollWindow.Top = -scrVertical.Value
End Sub

Private Sub scrVertical_Scroll()
  scrVertical_Change
End Sub
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990833
Hi mltolun,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rspahitz's comment(s) as an answer.

mltolun, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8053140
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 33
Why is "packages element is not declared"? 2 217
Spell Check in VB6 13 112
VBA: copy range dynamically based on config sheet v2 3 33
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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

770 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