Reputation: 1
i can't seem to find any exit function in my mfc application codes. i want my application to actually save some settings when i click on the red cross on the top right of the application. anyone knows where is this exit function located at? thanks
Upvotes: 0
Views: 7474
Reputation: 4663
If it is a dialog based application, I prefer the following code
void CMFC_dialogDlg::OnOK()
{
}
void CMFC_dialogDlg::OnCancel()
{
}
void CMFC_dialogDlg::OnClose()
{
//Call Save Function
CDialog::OnOK();
}
After adding the following code i will remove the Ok and Cancel button from the dialog so that i will prevent the application from closing while pressing Esc/Enter key.
Upvotes: 2
Reputation: 18441
Depends on what type of application it is. Check CWinApp::ExitInstance
which will be called always. You may also look into CDialog::OnCancel
, CWnd::OnClose
, CWnd::OnDestroy
, CFrameWnd::OnNcDestroy
Upvotes: 7