如何在MFC中创建非交互式窗口

发布于 2024-07-04 12:26:11 字数 174 浏览 13 评论 0原文

在我的应用程序中,我有一个弹出的窗口,上面有小消息(类似于工具提示)。 该窗口使用分层属性来绘制 alpha 背景等。

如果我同时打开其中几个窗口,然后用鼠标单击其中一个,当它们消失时,它们会导致我的应用程序失去焦点(它将焦点切换到窗口后面的应用程序)当前的一个)。

如何停止窗口中的任何交互?

In my application I have a window which I popup with small messages on it (think similar to tooltip). This window uses the layered attributes to draw alpha backgrounds etc.

If I have several of these windows open at once, and I click one with my mouse, when they disappear they cause my application to lose focus (it switches focus to the app behind the current one).

How do I stop any interaction in my window?

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

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

发布评论

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

评论(2

素染倾城色 2024-07-11 12:26:11

在尝试了 WM_NCACTIVATE 消息但没有成功后,我覆盖了 WM_SETFOCUS 消息:

void CMyWindow::OnSetFocus(CWnd* pOldWnd)
{
    if (pOldWnd != NULL)
    {
        pOldWnd->SetFocus();
    }
}

这似乎可以解决问题。 不知道为什么它会起作用! 欢迎对此问题发表评论。

After playing with the WM_NCACTIVATE message with no luck, I overrode the WM_SETFOCUS message:

void CMyWindow::OnSetFocus(CWnd* pOldWnd)
{
    if (pOldWnd != NULL)
    {
        pOldWnd->SetFocus();
    }
}

That seems to do the trick. No idea why it works though! Comments welcome on that issue.

彩虹直至黑白 2024-07-11 12:26:11

它之所以有效,是因为 OnSetFocus(与许多 On* 方法一样)使您有机会在操作实际发生之前抢占该操作。 焦点实际上从未切换到非交互式窗口。

It works because OnSetFocus (like many of the On* methods) gives you a chance to pre-empt an action before it actually occurs. The focus never actually switches to your non-interactive window.

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