C++ – How to close the main window in MFC dialog-based application

c++mfc

Can anybody answer how to close the main window in MFC dialog-based application when I want to close the application itself? The application was created in MS VS 2010.
Thank you very much in advance.

Eugene.

Best Solution

Try this:

ASSERT( AfxGetMainWnd()!=NULL );
AfxGetMainWnd()->SendMessage(WM_CLOSE);