寻找包含一个点的最小窗口:WindowFromPoint
2016-12-22 10:51
405 查看
1 搜寻包含一个点的最小窗口 /************************************************************************ // SmallestWindowFromPoint // Find the smallest window still containing the point // WindowFromPoint returns the first window in the Z-order // if the password control is sorounded by a Group Box or some other control, // WindowFromPoint returns the handle to the sorounding control instead // to the password control. ************************************************************************/ HWND SmallestWindowFromPoint(POINT point) { RECT rect, rcTemp; HWND hParent, hWnd, hTemp; hWnd = ::WindowFromPoint(point); if( hWnd != NULL ) { ::GetWindowRect(hWnd, &rect); hParent = ::GetParent(hWnd); // Has window a parent ? if(hParent != NULL) { // Search down the Z-Order hTemp = hWnd; do { hTemp = ::GetWindow(hTemp, GW_HWNDNEXT); // Search window contains the point, has the same parent, and is visible? ::GetWindowRect(hTemp, &rcTemp); if(::PtInRect(&rcTemp, point) && ::GetParent(hTemp) == hParent && ::IsWindowVisible(hTemp)){ // Is it smaller? if(((rcTemp.right - rcTemp.left) * (rcTemp.bottom - rcTemp.top)) < ((rect.right - rect.left) * (rect.bottom - rect.top))) { // Found new smaller window! hWnd = hTemp; ::GetWindowRect(hWnd, &rect); } } } while(hTemp != NULL); } } return hWnd; }
相关文章推荐
- WindowFromPoint -- 获得包含指定点的窗口的句柄
- 用WindowFromPoint()函数来获得鼠标所在位置的窗口的句柄--发生一个关闭窗口的消息---关闭鼠标所在的窗口
- 一个有意思的API——WindowFromPoint
- QQ截图时窗口自动识别的原理(WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx,RealChildWindowFromPoin
- 在一个字符串中找出包含特定字符串的最小窗口
- QQ截图时窗口自动识别的原理(WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx,RealChildWindowFromPoint)
- 易语言-API 取窗口或者组件句柄的 屏幕坐标并限制区域 GetWindowRect ClipCursor getwindowrect GetClientRect WindowFromPoint
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- [经典面试题][搜狗]在一个字符串中寻找包含全部出现字符的最小字串
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- C# winfrom中在一个主窗口包含子窗口
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- Minimum Window Substring, 包含子串的最小窗口,双指针
- 寻找在数组中一个元素是不是该行最小,该列最大的元素
- 创建一个窗口 -- From GameTutorials, LLC
- 如何把一个网页强制带参数跳转到一个框架包含窗口中
- Gridview中点击链接window.open一个新窗口(showModalDialog()、showModelessDialog()方法使用详解)
- WindowFromPoint
- 用window.showModalDialog()打开一个新窗口,但是提交的时候会打开一个新页面解决办法
- window.open 开一个新标签还是窗口设置