Close dialog box, onclose and oncancel

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.