Creating a Dialog Box that Users Can't Exit at Run Time

You can create a dialog box that a user cannot exit at run time. This type of dialog box is useful for logon screens and application or document locks.

To create a dialog box that users can't exit at run time

  1. In the Properties pane, disable the system menu and the Close button by setting the System Menu property to false.

  2. Delete the Cancel and OK buttons.

During run time, a user cannot exit a modal dialog box with these characteristics.

To allow testing of this type of dialog box, the test dialog box function detects the ESC keystroke, also known as the VK_ESCAPE virtual key. No matter how the dialog box will behave at run time, you can terminate it in test mode by pressing ESC.


For MFC applications, you need to override the default behavior of OnOKand OnCancel to create a dialog box that users can't exit at run time. For example, if you try doing the steps mentioned above on the About box of a default MFC wizard-generated application, you'll see that Esc and Enter will still dismiss the dialog box.

For information on adding resources to managed projects, please see Resources in Applications in the .NET Framework Developer's Guide. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resources strings to properties, see Walkthrough: Localizing Windows Forms and Walkthrough: Using Resources for Localization with ASP.NET.



See Also


Creating a New Resource


Resource Files (Visual Studio)

Dialog Editor