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.