Windows 静态控制如何阻止输入焦点

发布于 2024-09-16 20:39:09 字数 298 浏览 9 评论 0原文

我们知道Windows中的静态控制不接收输入焦点。但由于Windows中的静态控制只是一个子窗口,根据我目前的理解,任何窗口在我们点击它时都应该获得输入焦点。那么Static控件是如何实现这种拒绝输入焦点的效果的呢?我怀疑它在 WM_SETFOCUS 处理程序中进行了特殊处理,将输入焦点生成到其父窗口。然而,我做了一些测试,似乎子窗口实际上根本没有收到任何 WM_SETFOCUS ,即 Windows 从未真正尝试将输入焦点赋予静态控件。

我读过关于输入焦点的msdn,但没有与Windows如何为静态控制分配焦点相关的内容。谁能解释如何使静态控制没有输入焦点?

We know that Static Control in Windows does not receive input focus. But since Static Control in Windows is just a child window, according to what I understand so far, any window should be given input focus when we click on it. So how does Static control achieve this effect of rejecting input focus? I suspect it has special processing in its WM_SETFOCUS handler that yields the input focus to its parent window. However, I've done some tests and it seems that the child window really does not receipt any WM_SETFOCUS at all i.e. Windows never really tried to give input focus to the static control at all.

I've read the msdn on input focus and there is nothing related to how Windows allocate focus for static control. Can anyone explain how Static Control is made not to have input focus?

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

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

发布评论

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

评论(1

铁轨上的流浪者 2024-09-23 20:39:09

静态控件从其 返回 HTTRANSPARENT WM_NCHITTEST 处理程序。这会导致单击直接转到底层窗口(即父窗口)。 WM_MOUSEACTIVATEWM_*BUTTONCLICK 以及其他魔法最终会导致激活和 SetFocus

The static control returns HTTRANSPARENT from its WM_NCHITTEST handler. That causes the click to go directly to the underlying window (which is the parent). The WM_MOUSEACTIVATE and WM_*BUTTONCLICK and other magic eventually leads to an activation and SetFocus.

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