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?
See the MSDN page for CDialog. The last paragraph of that page provides detailed instructions for closing a modeless dialog.