Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top