|
-
June 4th, 1999, 12:01 PM
#1
VB And Scroll Bars
How does one get the tickness of a scroll bar on an OLE control. Is there a simple VB call out there...
-
June 4th, 1999, 03:49 PM
#2
Re: VB And Scroll Bars
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 :-)
-
June 11th, 1999, 02:36 PM
#3
Re: VB And Scroll Bars
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
-
June 12th, 1999, 04:34 AM
#4
Re: VB And Scroll Bars
Doesn't it work like this?
OLEViewGraphics.Width = frmViewGraphics.ScaleWidth
OLEViewGraphics.Height = frmViewGraphics.ScaleHeight
-
June 14th, 1999, 07:48 AM
#5
Re: VB And Scroll Bars
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|