多窗口程序

发布于 2024-09-07 04:39:42 字数 232 浏览 12 评论 0原文

我读了很多关于这个主题的文章,其中一些在 stackoverflow 上,但没有人问我的问题。我会尝试具体一点。

我需要创建一个带有主窗口(窗口类“a”)的应用程序(本机 WinAPI)。当用户单击那里的按钮时,会弹出一个“b”类窗口。它可能是模态的,也可能不是模态的,我现在不在乎。

我尝试制作一个具有两个窗口类和两个窗口过程的应用程序。但问题是,当我关闭第二个窗口时,整个应用程序都会关闭。

谢谢。

I read many articles on the topic, a few of them were here, on stackoverflow, but none of them asked my question. I'll try to be specific.

I need to create an application (native WinAPI) with a main window (of window class "a"). When the user clicks a button there, a window of "b" class pops up. It might be modal or not, I don't care right now.

I tried making an application with two window classes and two window procedures. But the problem is that when I close the second window, the whole application shuts down.

Thank you.

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

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

发布评论

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

评论(1

盗琴音 2024-09-14 04:39:42

据猜测,第二个窗口的窗口过程基于主窗口的窗口过程,因此当它收到 WM_DESTROY 时,它会调用 PostQuitMessage。这对于顶级窗口来说是正常的,因为用户期望销毁它就意味着退出应用程序。对于子窗口(模态窗口或其他窗口)而言,情况并非如此,因此子窗口不应该(同样,正常情况下)在其 WM_DESTROYPostQuitMessage > 处理程序。

At a guess, the window procedure for your second window is based on one for a main window, so when it receives a WM_DESTROY, it's calling PostQuitMessage. This is normal for the top-level window, because the user expects destroying it to mean exiting the application. For a child window (modal or otherwise) that's not the case though, so the child should not (again, normally) call PostQuitMessage in its WM_DESTROY handler.

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