查找哪个 MFC 子窗口将接收鼠标单击

发布于 2024-09-02 07:06:44 字数 212 浏览 6 评论 0原文

所以,我有一个 MFC 程序的插件。我正在使用鼠标事件挂钩(来自 SetWindowsHookEx)来捕获点击。主机应用程序可以打开任意数量(可能重叠)的子窗口,但我只想拦截特定子窗口中的点击。

有没有办法在钩子过程中找出哪个子窗口将处理点击?我想这就像枚举所有子窗口,查看 Z 顺序,但我对 MFC/Win32 库非常不熟悉,而且我找不到任何关于如何枚举所有子窗口并计算哪个是好的讨论最上面。

So, I have a plugin to an MFC program. I'm using a mouse event hook (from SetWindowsHookEx) to capture clicks. The host application can have any number of (possibly overlapping) child windows open, but I only want to intercept clicks in a particular child window.

Is there a way to figure out in the hook proc which of the child windows would process the click? I guess it's something like enumerate all child windows, looking at Z-order, but I'm very unfamiliar with the MFC/Win32 libraries, and I'm not able to find any good discussion about how to enumerate all children and calculate which is topmost.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淤浪 2024-09-09 07:06:44

也许WindowFromPoint API 函数符合要求吗?

检索包含指定点的窗口句柄。

该文档没有明确提及 Z 排序,但我可以根据第一手经验向您保证,“包含”隐含意味着前面没有其他窗口。

还有其他几个,其行为略有不同: ChildWindowFromPointChildWindowFromPointExRealChildWindowFromPoint

Maybe the WindowFromPoint API function fits the bill?

Retrieves a handle to the window that contains the specified point.

The documentation does not explicitly mention Z ordering, but I can assure you from first-hand experience that "contains" implicitly means that no other window is in front.

There are several more of these, with slightly different behaviour: ChildWindowFromPoint, ChildWindowFromPointEx and RealChildWindowFromPoint.

盗琴音 2024-09-09 07:06:44

自从我做 MFC 以来已经很长时间了,但我认为 HitTest 就是您正在寻找的术语。快速浏览 MSDN 表明大多数窗口都实现了 HitTest 函数,该函数返回有关特定点的信息。

It's been a long time since I did MFC, but I think that HitTest is the term you're looking for. A quick trawl through MSDN indicates that most windows implement a HitTest function that returns information about a particular point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文