c++user-interfacewinapimfcspy++

How to get the handle of a SysTreeView32's scrollbar?


I have a SysTreeView32 control with two associated scrollbars:

enter image description here

Starting from the window in which the tree is located, I am not able to recover the scrollbars' handles; I wrote a simple recursive function to navigate the control and all its children:

TestScroll( HWND hwnd, UINT msg, UINT_PTR nId, DWORD nTickCount)
{
    CWnd* pNextWnd = tmpWnd->GetWindow( GW_CHILD) ;

    if ( pNextWnd != NULL)
        TestScroll( pNextWnd->GetSafeHwnd(), msg, nId, nTickCount) ;

    pNextWnd = tmpWnd->GetNextWindow( GW_HWNDNEXT) ;

    if ( pNextWnd != NULL)
        TestScroll( pNextWnd->GetSafeHwnd(), msg, nId, nTickCount) ;

}

When I get to the SysTreeView32 control, I can't get further into the hierarchy and it seems that there are no more child controls; but Spy++ confirms that the scrollbars are indeed present.

Any advice is welcome, thank you very much!


Solution

  • Windows does provide a scrollbar class that can exist as a HWND but the treeview control (and most of the other common controls) use the other scrollbar type which is a part of the parent HWND (WS_HSCROLL and/or WS_VSCROLL styles).