|
1 | 1 | ---
|
2 |
| -title: "Creating a New Dialog Box (C++)" |
| 2 | +title: "Creating a Dialog Box (C++)" |
3 | 3 | ms.date: "11/04/2016"
|
4 | 4 | f1_keywords: ["vc.editors.dialog"]
|
5 |
| -helpviewer_keywords: ["dialog boxes [C++], creating", "Dialog Editor [C++], creating dialog boxes"] |
| 5 | +helpviewer_keywords: ["dialog boxes [C++], creating", "Dialog Editor [C++], creating dialog boxes", "modal dialog boxes [C++], logon screens", "logon screens"] |
6 | 6 | ms.assetid: 303de801-c4f8-42e1-b622-353f6423f688
|
7 | 7 | ---
|
8 |
| -# Creating a New Dialog Box (C++) |
| 8 | +# Creating a Dialog Box (C++) |
9 | 9 |
|
10 |
| -### To create a new dialog box |
| 10 | +For information on adding resources to managed projects, see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resource strings to properties, see [Creating Resource Files for Desktop Apps](/dotnet/framework/resources/creating-resource-files-for-desktop-apps). For information on globalization and localization of resources in managed apps, see [Globalizing and Localizing .NET Framework Applications](/dotnet/standard/globalization-localization/index). |
| 11 | + |
| 12 | +## To create a new dialog box |
11 | 13 |
|
12 | 14 | 1. In [Resource View](../windows/resource-view-window.md), right-click your .rc file, then choose **Add Resource** from the shortcut menu.
|
13 | 15 |
|
14 | 16 | > [!NOTE]
|
15 | 17 | > If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
|
16 | 18 |
|
17 |
| -2. In the **Add Resource** dialog box, select **Dialog** in the **Resource Type** list, then click **New**. |
| 19 | +1. In the **Add Resource** dialog box, select **Dialog** in the **Resource Type** list, then choose **New**. |
18 | 20 |
|
19 |
| - If a plus sign (**+**) appears next to the **Dialog** resource type, it means that dialog box templates are available. Click the plus sign to expand the list of templates, select a template, and click **New**. |
| 21 | + If a plus sign (**+**) appears next to the **Dialog** resource type, it means that dialog box templates are available. Select the plus sign to expand the list of templates, select a template, and choose **New**. |
20 | 22 |
|
21 | 23 | The new dialog box opens in the **Dialog** editor.
|
22 | 24 |
|
23 | 25 | You can also [open existing dialog boxes in the Dialog Box editor for editing](../windows/viewing-and-editing-resources-in-a-resource-editor.md).
|
24 | 26 |
|
25 |
| -For information on adding resources to managed projects, please see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resource strings to properties, see [Creating Resource Files for Desktop Apps](/dotnet/framework/resources/creating-resource-files-for-desktop-apps). For information on globalization and localization of resources in managed apps, see [Globalizing and Localizing .NET Framework Applications](/dotnet/standard/globalization-localization/index). |
| 27 | +## To create a dialog box that a user can't exit |
| 28 | + |
| 29 | +You can create a runtime dialog box that a user can't exit. This kind of dialog box is useful for logons, and for application or document locks. |
| 30 | + |
| 31 | +1. In the **Properties** pane for the dialog box, set the **System Menu** property to **false**. |
| 32 | + |
| 33 | + This setting disables the dialog box system menu and **Close** button. |
| 34 | + |
| 35 | +1. In the dialog box form, delete the **Cancel** and **OK** buttons. |
| 36 | + |
| 37 | + At run time, a user can't exit a modal dialog box that has these characteristics. |
| 38 | + |
| 39 | +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 end test mode by pressing **Esc**. |
| 40 | + |
| 41 | +> [!NOTE] |
| 42 | +> For MFC applications, to create a dialog box that users cannot exit, you must override the default behavior of `OnOK` and `OnCancel` because even if you delete the associated buttons, the dialog box can still be dismissed by pressing **Enter** or **Esc**. |
| 43 | +
|
| 44 | +For information about how to add resources to managed projects, see [Resources in Desktop Apps](/dotnet/framework/resources/index). |
26 | 45 |
|
27 | 46 | ## Requirements
|
28 | 47 |
|
|
0 commit comments