I'm calling EndDialog(IDCLOSE) to end the application in a class inheriting CDialogImpl and I get a Debug Assertion Failed run time error on ATLASSUME(m_bModal) in CDialogImpl::EndDialog(int). What am I doing wrong?

有帮助吗?

解决方案

EndDialog is meant to close a modal dialog and should not be used for a dialog-based application. To terminate an application call CWindow::DestroyWindow instead.

This is one of the places where the encapsulation breaks and the implementation exposes implementation details to the user. EndDialog performs additional operations on top of destroying the dialog window. The additional work (like storing the return value) is meaningless for a dialog-based application. The result is that you have to call different methods to terminate a dialog depending on context.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top