CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    26

    scroll bar width

    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



  2. #2
    Join Date
    May 1999
    Posts
    26

    Re: scroll bar width

    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?



  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: scroll bar width

    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

  4. #4
    Join Date
    May 1999
    Posts
    26

    Re: scroll bar width

    Thank you Ravi !!


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