We know that in the dialog box, you can choose to reload oncancel as a dummy function by blocking the ESC key and automatically Exit:
Void cxxxxdlg: oncancel ()
{
// Todo: add your specialized code here and/or call the base class
// Cdialog: oncancel (); // disable oncancel
}
However, in this way, closing the button in the upper right corner does not work, because when you click to close the button, you will automatically call cxxxxdlg: oncancel () L to close the dialog box, because cxxxxdlg:: The dialog box cannot be closed because nothing is done in oncancel. To modify this bug, you need to reload the onclose message function:
Void cxxxxdlg: onclose ()
{
// Todo: add your message handler code here and/or call default
Cdialog: oncancel (); // Add oncancel here
Cdialog: onclose ();
}
Because oncancle actually calls enddicel (idcancel), you can also follow the following changes:
Void cxxxxdlg: onclose ()
{
// Todo: add your message handler code here and/or call default
Enddicel (idcancel );
Cdialog: onclose ();
}
We know that the onclose function is the response function of the wm_close message, but why does it automatically call cxxxxdlg: oncancel () after the wm_close message is sent ()? I followed the code and roughly sorted out the process:
Wm_close
-> Enter void cxxxxdlg: onclose ()
-> Cdialog: onclose ()
->Void cxxxxdlg: onclose () returns
-> Void cxxxxdlg: oncancel ()
What is more amazing than counter is the cdialog: onclose () function:
This function does not know how to tell the system to call cxxxxdlg: onclose () after cxxxxdlg: oncancel () is returned. In debugging, assume that this function is staring away, it is not transferred to the cxxxxdlg: oncancel () function. In addition, the cxxxxdlg: oncancel () function is called after cxxxxdlg: onclose () is returned, assuming that the response uses a message, I think whether it should not be called after the return, the message should be processed immediately after being sent.
I have not obtained an answer for a long time on the Internet. I have recorded a temporary record here. Maybe I have made it clear one day, or I have been found to give a answer.
Close dialog box, onclose and oncancel