用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 ValueReturns 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的,不检索窗口被隐藏的,不返回这两个类型的句柄.
相关文章推荐
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- WindowFromPoint -- 获得包含指定点的窗口的句柄
- WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
- Sessions, Window Stations and Desktops(GetDesktopWindow函数得到的桌面句柄, 是Csrss.exe创建的一个窗口)
- 易语言-API 取窗口或者组件句柄的 屏幕坐标并限制区域 GetWindowRect ClipCursor getwindowrect GetClientRect WindowFromPoint
- Sessions, Window Stations and Desktops(GetDesktopWindow函数得到的桌面句柄, 是Csrss.exe创建的一个窗口)
- 寻找包含一个点的最小窗口:WindowFromPoint
- 取鼠标所在位置对应的窗口句柄
- WindowFromPoint -- 获得包括指定点的窗体的句柄
- GetCapture获得一个窗口的句柄,这个窗口位于当前输入线程,且拥有鼠标捕获(鼠标活动由它接收)
- elementFromPoint 获得鼠标所在位置处的对象
- 建立控制台程序--获得已经打开的一个窗口的句柄--给这个窗口发送一个关闭命令
- 不知道在MFC中如何从线程工作函数中向窗口发送消息?用好一个指针就够了
- 创建一个窗口window.open,检查窗口是否已关闭或不
- Delphi中一个获得窗口图象的函数
- 判断特定窗口是否存在、线程中获取获得一个顶层窗口的句柄
- MFC应用程序中处理消息,创建窗口的过程,关闭窗口(非模态窗口),打开模式对话框等的函数调用顺序
- TrackMouseEvent函数在鼠标离开某一窗口或在某一窗口上停留超过某一特定时间长度时发送消息(转)
- 使用window.close关闭窗口后,出现一个新的页面问题