Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can check if a Window has visible scrollbars using his HWND?

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.

like image 654
Salvador Avatar asked Mar 17 '12 16:03

Salvador


1 Answers

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

like image 137
kobik Avatar answered Oct 19 '22 06:10

kobik