Share via


Creating a Dialog Box That Users Cannot Exit

 

The latest version of this topic can be found at Creating a Dialog Box That Users Cannot Exit.

The latest version of this topic can be found at Creating a Dialog Box That Users Cannot Exit.

You can create a runtime dialog box that a user cannot exit. This kind of dialog box is useful for logons, and for application or document locks.

To create a dialog box that a user cannot exit

  1. In the Properties pane for the dialog box, set the System Menu property to false.

    This disables the dialog box system menu and Close button.

  2. In the dialog box form, delete the Cancel and OK buttons.

    At run time, a user cannot exit a modal dialog box that has these characteristics.

To enable testing of this kind of dialog box, the test dialog box function detects when ESC is pressed. (ESC is also known as the VK_ESCAPE virtual key.) No matter how the dialog box is designed to behave at run time, you can terminate it in test mode by pressing ESC.

Note

For MFC applications, to create a dialog box that users cannot exit, you must override the default behavior of OnOKand OnCancel because even if you delete the associated buttons, the dialog box can still be dismissed by pressing ENTER or ESC.

For information about how to add resources to managed projects, see Resources in Desktop Apps.

Requirements

Win32

See Also

How to: Create a Resource
Resource Files
Dialog Editor