Link to home
Start Free TrialLog in
Avatar of cspl
cspl

asked on

Scroll Bar

SUB: Does a Form/Frame/SSTab do support scrollbar property...if so,how do i implement the same.

    Well the problem i encounter is, when i try to restore the form which is in maximized mode, my sstab control goes out of focus i.e i dont get either horizontal scroll bar or vertical scroll bar. Similarly when the form is restored the frame control also goes out of focus, which again doesnt have the scroll bars. And the problem seem to presist for the form as well..when it is restored the controls on the form goes out of focus. So all i request is , do u have any solution for this or is there is any way/option to go about with this.

Awaiting your reply

Regards
CSPL Team.
Avatar of cspl
cspl

ASKER

Ancipating your reply
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
' It is possible to show scrollbars on most controls with hwnd property.
'    But catching events from that scrollbar is too hardcore, so use this instead:

' Here is a sample of vertical scrolling of the form
' You will need your own container (picturebox) and vertical scrollbar
'   all your controls should be seated on that container, not on your form

' Form1, add one picturebox and one vertical scrollbar
' add some controls to container (e.g. few textboxes)
Option Explicit

Private Sub Form_Load()
    VScroll1.Width = 17 * Screen.TwipsPerPixelX
    VScroll1.TabStop = False
End Sub

Private Sub Form_Resize()
    On Error Resume Next
    If WindowState <> vbMinimized Then
        VScroll1.Move ScaleWidth - VScroll1.Width, 0, VScroll1.Width, ScaleHeight
        Picture1.Move 0, 0
        Adjust
    End If
End Sub

Private Sub VScroll1_Change()
    Pos
End Sub

Private Sub VScroll1_Scroll()
    Pos
End Sub

Sub Pos()
    Picture1.Top = -VScroll1.Value
End Sub

Sub Adjust()
   ' set 3 properties of vert scrollbar
   VScroll1.Value = 0
   If Picture1.Height < ScaleHeight Then ' no need to scroll
       VScroll1.Max = 0
       VScroll1.Visible = False
   Else
       VScroll1.Visible = True
       VScroll1.Max = Abs(ScaleHeight - Picture1.Height)
   End If
   VScroll1.LargeChange = ScaleHeight
End Sub
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to aikimark
Please leave any comments here within the
next seven days.
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange