CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2001
    Location
    the Netherlands (Holland), Europe
    Posts
    15

    Scroll bar must size to Windows settings

    I use a scroll bar. But it has always the same size. I want it to have the right size which is chosen in the Windows settings.
    Can someone tell me how to do this, or where in the registry I can find the correct size?
    Thanks.

    Peter Moor

  2. #2
    Join Date
    Aug 2000
    Location
    KY
    Posts
    766

    Re: Scroll bar must size to Windows settings

    I think all you need is some resize code, paste this into your form and as you move the form it will always keep the scroll bar the right size.


    private Sub Form_Resize()
    on error resume next
    If me.WindowState = vbMinimized then Exit Sub
    VScroll1.Move me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, me.ScaleHeight
    End Sub





  3. #3
    Join Date
    Sep 1999
    Posts
    202

    Re: Scroll bar must size to Windows settings

    Form1; to test, change window sheme to e.g. "Rainy Day" and click on form.
    option Explicit
    private Declare Function GetSystemMetrics Lib "user32" (byval nIndex as Long) as Long
    private Const SM_CXVSCROLL = 2
    private Const SM_CYHSCROLL = 3

    private Sub Form_Click()
    ' resize controls
    Controls!vsb1.Width = ScaleX(GetSystemMetrics(SM_CXVSCROLL), vbPixels)
    Controls!hsb1.Height = ScaleX(GetSystemMetrics(SM_CYHSCROLL), vbPixels)

    print "vert. scrollbar width:" & GetSystemMetrics(SM_CXVSCROLL) & " pixels"
    print "horz. scrollbar height:" & GetSystemMetrics(SM_CYHSCROLL) & " pixels"
    End Sub

    private Sub Form_Load()
    With Controls.Add("vb.vscrollbar", "vsb1")
    .Width = 500
    .Left = 2400
    .Visible = true
    End With
    With Controls.Add("vb.hscrollbar", "hsb1")
    .Height = 500
    .Left = 3000
    .Visible = true
    End With
    End Sub





  4. #4
    Join Date
    Jan 2001
    Location
    the Netherlands (Holland), Europe
    Posts
    15

    Re: Scroll bar must size to Windows settings

    Actually that was not what I meant, but thanks anyway.

    Peter Moor

  5. #5
    Join Date
    Jan 2001
    Location
    the Netherlands (Holland), Europe
    Posts
    15

    Now with statusbars

    I don't know if the size of statusbars can also be configured by Windows, but if it does, can I use this way to get that size too?

    Peter Moor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured