Share via


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 Applications. For information about how to manually add resource files to managed projects, access resources, display static resources, and assign resources strings to properties, see Walkthrough: Localizing Windows Forms and Walkthrough: Using Resources for Localization with ASP.NET.

Requirements

Win32

See Also

Tasks

How to: Create a Resource

Reference

Resource Files (Visual Studio)

Dialog Editor