如何在不关闭父窗口的情况下关闭子窗口?
我有一个有 5 个子窗口的窗口。如何在不关闭父窗口的情况下关闭子窗口?
I have a window which has 5 child windows. How can I close a child window without closing the parent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
想必您有子窗口的句柄?如果是这样,则只需使用
DestroyWindow
< /a>.编辑:
您应该在主“窗口”中定义一个 WndProc 方法来处理来自子窗口的回调。您可以使用它来定义要对每条消息执行的操作。在你的情况下,你想调用 destroyWindow。
像这样的事情:
Presumably you have handles for the child windows? If so, then just use
DestroyWindow
.EDIT:
You should define a WndProc method in your main 'window' to handle callbacks from your child windows. You use this to define what you want to do with each message. In your case, you want to call destroyWindow.
Something like this:
这件事就发生在我身上。我已将一个案例
WM_DESTROY
添加到为子窗口注册的窗口过程中。这导致我的整个应用程序退出。移除后,一切正常。This was happening to me. I had added a case
WM_DESTROY
to the window procedure I registered for my child windows. This was causing my entire application to quit. Once removed, everything worked good.我遇到了同样的问题,所以我这样做来解决它:
创建一个全局句柄变量,它将用作对主父窗口的引用。
在首次创建父窗口的程序的主函数中,我这样做了:
然后,在 LRESULT 方法中,我执行了以下操作:
我希望它有帮助。快乐编码!
I had the same problem so I did this to solve it:
Create a global handle variable the will be used as a reference to the main parent window.
In the main function of the program where the parent window is first created I did this:
Then, in the LRESULT method I did this:
I hope it helps. Happy coding!