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

    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...


  2. #2
    Join Date
    Apr 1999
    Location
    Rotterdam, Netherlands
    Posts
    278

    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 :-)


  3. #3
    Join Date
    Jun 1999
    Posts
    26

    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






  4. #4
    Join Date
    Apr 1999
    Location
    Rotterdam, Netherlands
    Posts
    278

    Re: VB And Scroll Bars

    Doesn't it work like this?
    OLEViewGraphics.Width = frmViewGraphics.ScaleWidth
    OLEViewGraphics.Height = frmViewGraphics.ScaleHeight


  5. #5
    Join Date
    Jun 1999
    Posts
    26

    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
  •  





Click Here to Expand Forum to Full Width

Featured