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.