I want to check if the window of an external application has the vertical or horizontal scrollbar visible using the HWND (handle) of the window, exist any WinApi function to get this information? I really try the GetScrollInfo
function but it seems that not retrieve information about the visibility of the scrollbars.
Asked
Active
Viewed 4,979 times
8

Salvador
- 16,132
- 33
- 143
- 245
1 Answers
17
How about GetScrollBarInfo
with OBJID_HSCROLL
or OBJID_VSCROLL
If idObject is OBJID_CLIENT and the window specified by hwnd is not a system scroll bar control, the system sends the SBM_GETSCROLLBARINFO message to the window to obtain scroll bar information. This allows GetScrollBarInfo to operate on a custom control that mimics a scroll bar. If the window does not handle the SBM_GETSCROLLBARINFO message, the GetScrollBarInfo function fails.
You can test rgstate
in the SCROLLBARINFO
structure, there is a STATE_SYSTEM_INVISIBLE
flag there.
Another possible way is to test GetWindowLong(hWnd, GWL_STYLE) and (WS_HSCROLL or WS_VSCROLL) <> 0

kobik
- 21,001
- 4
- 61
- 121
-
looks promising, but doesn't work with the Internet Explorer windows or Explorer.exe applications (Windows 7) – Salvador Mar 17 '12 at 17:33
-
1I believe that `Explorer.exe` contains the controls `SysTreeView32` and `SysListView32` (both return valid `WS_HSCROLL` or `WS_VSCROLL`) with `GetWindowLong`. I use Spy++ to confirm the window styles. didn't test with `GetScrollBarInfo` though. – kobik Mar 17 '12 at 18:00