The enter key and ESC key are blocked in the dialog box.

Source: Internet
Author: User
The enter key and ESC key are blocked in the dialog box.

Dialog Box-based applicationsProgramFor the Enter key and ESC key, a response function is provided when the project is created, namely:
Void cxxxdialog: onok (); and void cxxxdialog: oncancel ()
Of the two functions, there is only one sentence.CodeCdialog: onok (); and cdialog: oncancel
This may cause a problem: After you press the Enter key and ESC key, the dialog box structure will disappear. The difference is that after you press the Enter key, domodal
Idcancel is returned by domodal after pressing the ESC keyboard.

However, most of the time we do not want to press the Enter key and ESC key to exit the dialog box, so we should block these two cases, as follows:
First, add the following content to the. h file in the dialog box:
Virtual void onok ();
Virtual void oncancel ();
Then write the code for these two functions in the CPP file:
Void cxxxdialog: onok ()
{
// Do nothing
// Cdialog: onok ();
}
Void cxxxdialog: oncancel ()
{
// Do nothing
// Cdialog: oncancel ();
}

Then, you can place buttons such as "OK" and "cancel" on the dialog box, and write the code cdialog: onok in the response function of these buttons to exit the dialog box.

Note: If the dialog box is placed on a tab, you must disable the Enter key and ESC key. Otherwise, press the Enter key or ESC key on the tab to display the page content.
Disappear.

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.