Click to See Complete Forum and Search --> : scroll bar width


Sergio Acosta
December 9th, 1999, 09:04 PM
Hi, How do i know the width of the scroll bar

I`ve tried this :

Private Const SM_CXVSCROLL = 2
Private Const SM_CYHSCROLL = 3
rivate Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

but GetSystemMetrics(SM_CXVSCROLL) and GetSystemMetrics(SM_CYHSCROLL)

returns 16 and 16 each.

Is not possible for the scrollbar to be 16 pix width

Sergio Acosta
December 10th, 1999, 12:44 AM
I have a form with a multiline textbox. I want the textbox to fit complety in the form, so when i resize the form i also resize the textbox.

But, when I add one or both scrollbars to the textbox it becomes bigger than it was first.

I donīt understand the way the scrollbars behave. Are they inside the textbox, outside or in the middle? I havenīt found it out.

This is my code:


option Explicit

private Const SM_CXVSCROLL = 2
private Const SM_CYHSCROLL = 3

private Declare Function GetSystemMetrics Lib "user32" (byval nIndex as Long) as Long

private Sub Form_Resize()

If WindowState = vbMinimized then Exit Sub

Text1.Width = Width - GetSystemMetrics(SM_CXVSCROLL) - Text1.Left
Text1.Height = Height - GetSystemMetrics(SM_CYHSCROLL) - Text1.Top

End Sub




Would you help me, please?

Ravi Kiran
December 10th, 1999, 03:30 AM
For text boxes Scroll bars are inside the text box.
--
GetSytemMetrics returns the Scroll bar width in PIXELS. But by width we mean the width of a Vertical Scroll bar and "Height" of a Horiz. SB.
--
Since SBs are inside the text box, you dont need to correct for their widths.
So just do this:

private Sub Form_Resize()

If WindowState = vbMinimized then Exit Sub

Debug.Assert (me.ScaleWidth = VbTwips ) or (me.ScaleWidth = VbPixels)

Text1.Move 0,0, me.ScaleWidth , me.Scaleheight

End Sub




ScaleWidth & Scaleheight would be defined On the same scale on which the Move method takes its values.
Also ScaleWidth would be adjusted for the Forms Border etc, essentially the Client Size of the Form

RK

Sergio Acosta
December 10th, 1999, 10:30 AM
Thank you Ravi !! :)