Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jun 5, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Correctly set scrollbars' width and height

You should always modify a vertical scrollbar's width and a horizontal scrollbar's height to conform to the display resolution. You can learn the suggested size (in pixels) using the GetSystemMetrics API function, then convert it to twips, and rezise all the scrollbars on your forms accordingly. The following routine, however, does everything automatically:

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) _
    As Long

Sub ResizeAllScrollbars(frm As Object)
    Dim hsbHeight As Single
    Dim vsbWidth As Single
    Dim ctrl As Control

    Const SM_CXVSCROLL = 2
    Const SM_CYHSCROLL = 3
    ' Determine suggested scrollbars' size (in twips)
    hsbHeight = GetSystemMetrics(SM_CYHSCROLL) * Screen.TwipsPerPixelY
    vsbWidth = GetSystemMetrics(SM_CXVSCROLL) * Screen.TwipsPerPixelX

    ' iterate on all the controls on the form
    For Each ctrl In Controls
        Select Case TypeName(ctrl)
            Case "HScrollBar"
                ctrl.Height = hsbHeight
            Case "VScrollBar"
                ctrl.Width = vsbWidth
            Case "FlatScrollBar"
                If ctrl.Orientation = 1 Then
                    ctrl.Height = hsbHeight
                    ctrl.Width = vsbWidth
                End If
        End Select

End Sub
Marco Losavio
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date