Solved

Scroll Bars Component for Visual Basic

Posted on 2002-07-07
4
203 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 34
Excel - Save a copy of work book 13 79
Trouble with References... 5 21
Spell Check in VB6 13 39
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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

728 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

14 Experts available now in Live!

Get 1:1 Help Now