如何关闭在C ++中的无模式MFC对话框 [英] How to close a modeless MFC dialog in C++

查看:269
本文介绍了如何关闭在C ++中的无模式MFC对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无模式对话框,当我关闭我的主要应用程序时,有时留在屏幕上。如果我手动关闭它,所有析构函数正确调用。但是到目前为止,如果我试图通过C ++代码,我遇到问题,在Debug构建,不给我信心的发布版本中发生了什么。

I have a modeless dialog that is sometimes left up on the screen when I go to close my main app. If I close it manually, all destructors get called properly. But so far, if I try to do it through C++ code, I encounter problems in the Debug build that don't give me confidence in what is happening in the Release build.

关闭模型对话框的正确方法是什么?文档 PostQuitMessage()表示它关闭整个线程(是在一个单独的线程中运行的无模式对话,还是单个MFC App UI线程的一部分)。调用 DestroyWindow()给我在实践中的问题。发送 WM_CLOSE 不会觉得正确的事情。 CWnd :: EndDialog()仅适用于模态对话框。

What is the correct way to close a modelss dialog? Documentation for PostQuitMessage() indicates it closes entire threads (is a modeless dialog run in a separate thread, or just part of the single MFC App UI thread?). Calling DestroyWindow() gives me issues in practice. Sending a WM_CLOSE doesn't feel like the right thing to do. And CWnd::EndDialog() only applies to Modal dialogs. Does the correct answer lie among these... or somewhere else?

推荐答案

查看MSDN页面 CDialog 。该页的最后一段提供了关于关闭无模式对话框的详细说明。

See the MSDN page for CDialog. The last paragraph of that page provides detailed instructions for closing a modeless dialog.

这篇关于如何关闭在C ++中的无模式MFC对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆