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

﹥>﹥吖頭↗ 提交于 2020-02-18 21:35:30

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/9751740/how-i-can-check-if-a-window-has-visible-scrollbars-using-his-hwnd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!