您的位置:首页 > 其它

用WindowFromPoint()函数来获得鼠标所在位置的窗口的句柄--发生一个关闭窗口的消息---关闭鼠标所在的窗口

2017-10-14 11:22 447 查看
#include "stdafx.h"#include <Windows.h>int _tmain(int argc, _TCHAR* argv[]){ POINT curpos; while (TRUE) {  GetCursorPos(&curpos);  HWND wnd = WindowFromPoint(curpos);  SendMessage(wnd, WM_CLOSE, 0, 0);  Sleep(1000); }  return 0;}
HWND WindowFromPoint(
POINT Point
);
Return Value
Returns a handle to the window that contains the x-y coordinates to indicate success. Returns NULL to indicate that no window exists at the specified x-y coordinates.//返回一个句柄,表示成功,返回NULL表示失败. 返回的这个窗口句柄是: 鼠标curpos结构体所在窗口里面的句柄被返回.//句柄是一个整数.RemarksThe WindowFromPoint function does not retrieve a handle to a hidden or disabled window, even if the x-y coordinate is within the window. To determine if child windows of a parent window contain an x-y coordinate, use the ChildWindowFromPoint function.//这个函数不检索窗口被disabled的,不检索窗口被隐藏的,不返回这两个类型的句柄.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐