Click to See Complete Forum and Search --> : VB And Scroll Bars


Hugo
June 4th, 1999, 12:01 PM
How does one get the tickness of a scroll bar on an OLE control. Is there a simple VB call out there...

Crazy D
June 4th, 1999, 03:49 PM
Hi
As far as I know, all scrollbars in windooz have the same size.. so you can use the GetSystemMetrics function to retreive them.
This comes from the MSDn help:
SM_CXHSCROLL, SM_CYHSCROLL
Width, in pixels, of the arrow bitmap on a horizontal scroll bar; and height, in pixels, of a horizontal scroll bar.
SM_CXVSCROLL, SM_CYVSCROLL
Width, in pixels, of a vertical scroll bar; and height, in pixels, of the arrow bitmap on a vertical scroll bar.

private Declare Function GetSystemMetrics Lib "user32" (byval nIndex as Long) as Long
private Const SM_CXVSCROLL = 2
private Const SM_CYHSCROLL = 3
private Const SM_CYVSCROLL = 20
private Const SM_CXHSCROLL = 21

' use like:
' (the return value is in pixels, so * Screen.TwipsPerPixelX is to make twips of them...
Width_Of_Vertical_Scrollbar = GetSystemMetrics(SM_CXVSCROLL) * Screen.TwipsPerPixelX



Hope this helps

Crazy D :-)

Hugo
June 11th, 1999, 02:36 PM
CrazyD,

I tried what you said, but it didn't quite work. What I'm actually trying to do is resize an Ole control as the for is resized, so that the two stay in proportion. This is what I have right now, but the scroll bar sizes returned are not accurate. Is there another way to do this stuff in VB.


private Sub Form_Resize()
If Not (frmViewGraphics.WindowState = vbMinimized) then
OLEViewGraphics.Width = frmViewGraphics.Width - GetSystemMetrics(SM_CXVSCROLL) * Screen.TwipsPerPixelX
OLEViewGraphics.Height = frmViewGraphics.Height - GetSystemMetrics(SM_CYHSCROLL) * Screen.TwipsPerPixelX
End If
End Sub

Crazy D
June 12th, 1999, 04:34 AM
Doesn't it work like this?
OLEViewGraphics.Width = frmViewGraphics.ScaleWidth
OLEViewGraphics.Height = frmViewGraphics.ScaleHeight

Hugo
June 14th, 1999, 07:48 AM
CrazyD,

Thanks!!! It works when you subtract the thickness of the scroll bar. I was using the "Height and Width" form properties instead of the ScaleHeight and width.

Hugo