CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Scroll Scroll

  1. #1
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Scroll Scroll

    If you have two controls and each one has a vertical bar. Is there a way that when you scroll down or up on one the second follow the same trend.

    Please, let me know if I can connect between the two scroll bars.

    Thanks
    Hisham
    Thank You, Hisham

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Scroll Scroll

    'this code will let you grab the scroll bar position.
    'I did not try but I think you can set the second scroll bar tot the same position

    Private Const SB_CTL = 2
    Private Const SB_HORZ = 0
    Private Const SB_VERT = 1
    '
    Private Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long
    '
    Private Type SCROLLINFO
    cbSize As Long
    fMask As Long
    nMin As Long
    nMax As Long
    nPage As Long
    nPos As Long
    nTrackPos As Long
    End Type
    '
    Private Const SIF_RANGE As Long = &H1
    Private Const SIF_PAGE As Long = &H2
    Private Const SIF_POS As Long = &H4
    Private Const SIF_DISABLENOSCROLL As Long = &H8
    Private Const SIF_TRACKPOS As Long = &H10
    Private Const SIF_ALL As Long = (SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS)
    '
    Public Enum eScrollBar
    sbHorizontal = 0
    sbVertical = 1
    End Enum
    '
    Public Function GetScrollBarPos(ByVal lHwnd As Long, ByVal ScrollBar As eScrollBar) As Long
    '
    Dim lFlag As Long
    Dim sbInfo As SCROLLINFO
    Dim lRet As Long
    '
    sbInfo.cbSize = Len(sbInfo)
    sbInfo.fMask = SIF_POS
    lFlag = ScrollBar
    '
    lRet = GetScrollInfo(lHwnd, lFlag, sbInfo)
    '
    If lRet > 0 Then ' ok
    GetScrollBarPos = sbInfo.nPos
    End If
    '
    End Function



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: Scroll Scroll

    Will this also work for a scroll bar that comes with the MSFlexGrid Control?

    Thanks
    Hisham
    Thank You, Hisham

  4. #4
    Join Date
    Apr 2002
    Location
    WA
    Posts
    34

    Unhappy Re: Scroll Scroll

    This is a great sample, but does not work on the Properties dialog box from Device Manager. Does anyone know why? It worked with other windows. I also have the correct hWnd value.....

    Thanks,

    --- nicepat

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