Click to See Complete Forum and Search --> : Scroll bar must size to Windows settings


Peter Moor
February 1st, 2001, 05:37 AM
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

dfwade
February 1st, 2001, 08:37 AM
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

Bruno
February 1st, 2001, 09:51 AM
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

Peter Moor
February 1st, 2001, 12:10 PM
Actually that was not what I meant, but thanks anyway.

Peter Moor

Peter Moor
February 18th, 2001, 08:05 AM
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