How to close a modeless MFC dialog in C++

2019-08-08 02:01发布

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.

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?

标签: c++ mfc dialog
1条回答
贪生不怕死
2楼-- · 2019-08-08 02:48

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

查看更多
登录 后发表回答