|
2 | 2 | title: "Adding a Control to a Dialog Box (C++)" |
3 | 3 | ms.date: "11/04/2016" |
4 | 4 | f1_keywords: ["vc.editors.dialog.dialog"] |
5 | | -helpviewer_keywords: ["dialog boxes [C++], adding controls to"] |
| 5 | +helpviewer_keywords: ["dialog boxes [C++], adding controls to", "Toolbox [C++], Dialog Editor tab", "controls [C++], types", "syslink controls in dialog boxes", "custom controls [C++], dialog boxes", "controls [C++], standard", "Dialog Editor [C++], creating controls", "controls [C++], adding to dialog boxes", "controls [C++], adding multiple", "dialog box controls [C++], size", "controls [C++], sizing"] |
6 | 6 | ms.assetid: b2a26d19-093f-49ca-93da-fef00dfbb381 |
7 | 7 | --- |
8 | 8 | # Adding a Control to a Dialog Box (C++) |
9 | 9 |
|
10 | | -### To add a control to a dialog box |
| 10 | +The **Dialog Editor** tab appears in the [Toolbox window](/visualstudio/ide/reference/toolbox) when you're working in the **Dialog** editor. To add controls to your new dialog box, drag controls from the **Toolbox** to the dialog box you're creating. You can then move the controls around or change their size and shape. |
11 | 11 |
|
12 | | -1. Ensure that the dialog box tabbed window is the current document in the editor frame. If a dialog is not the current document, you won't see the **Dialog Editor Tab** in the **Toolbox**. |
| 12 | +The standard controls available in the **Toolbox** are: |
13 | 13 |
|
14 | | -2. On the [Dialog Editor Tab](../windows/dialog-editor-tab-toolbox.md) of the [Toolbox Window](/visualstudio/ide/reference/toolbox), select the control you want, then: |
| 14 | +- [Button control](../mfc/reference/cbutton-class.md) |
15 | 15 |
|
16 | | - - Click the dialog box at the location where you want to place the control. The control appears where you've clicked. For information, see [Adding Multiple Controls](../windows/adding-multiple-controls.md). |
| 16 | +- [Check Box control](../mfc/reference/styles-used-by-mfc.md#button-styles) |
| 17 | + |
| 18 | +- [Combo Box control](../mfc/reference/ccombobox-class.md) |
| 19 | + |
| 20 | +- [Edit control](../mfc/reference/cedit-class.md) |
| 21 | + |
| 22 | +- Group box |
| 23 | + |
| 24 | +- [List Box control](../mfc/reference/clistbox-class.md) |
| 25 | + |
| 26 | +- [Radio Button control](../mfc/reference/styles-used-by-mfc.md#button-styles) |
| 27 | + |
| 28 | +- [Static Text control](../mfc/reference/cstatic-class.md) |
| 29 | + |
| 30 | +- [Picture control](../mfc/reference/cpictureholder-class.md) |
| 31 | + |
| 32 | +- [Rich Edit 2.0 control](../mfc/using-cricheditctrl.md) |
| 33 | + |
| 34 | +- [Scroll bar control](../mfc/reference/cscrollbar-class.md) |
| 35 | + |
| 36 | +The [Windows Common Controls](../mfc/controls-mfc.md) available in the **Toolbox** provide increased functionality in your application. They include: |
| 37 | + |
| 38 | +- [Slider control](../mfc/slider-control-styles.md) |
| 39 | + |
| 40 | +- [Spin control](../mfc/using-cspinbuttonctrl.md) |
| 41 | + |
| 42 | +- [Progress control](../mfc/styles-for-the-progress-control.md) |
| 43 | + |
| 44 | +- [Hot Key control](../mfc/using-a-hot-key-control.md) |
| 45 | + |
| 46 | +- [List control](../mfc/list-control-and-list-view.md) |
| 47 | + |
| 48 | +- [Tree control](../mfc/tree-control-styles.md) |
| 49 | + |
| 50 | +- [Tab control](../mfc/tab-controls-and-property-sheets.md) |
| 51 | + |
| 52 | +- [Animation control](../mfc/using-an-animation-control.md) |
| 53 | + |
| 54 | +- [Date Time Picker control](../mfc/creating-the-date-and-time-picker-control.md) |
| 55 | + |
| 56 | +- [Month Calendar control](../mfc/month-calendar-control-examples.md) |
| 57 | + |
| 58 | +- [IP Address control](../mfc/reference/cipaddressctrl-class.md) |
| 59 | + |
| 60 | +- [Extended Combo Box control](../mfc/creating-an-extended-combo-box-control.md) |
| 61 | + |
| 62 | +- [Custom control](custom-controls-in-the-dialog-editor.md) |
| 63 | + |
| 64 | +You can add custom controls to the dialog box by selecting the **Custom Control** icon in the **Toolbox** and dragging it to your dialog box. To add a **Syslink** control, add a custom control, then change the control's **Class** property to **Syslink**. This will cause the properties to refresh and show the **Syslink** control properties. For information on the MFC wrapper class, see [CLinkCtrl](../mfc/reference/clinkctrl-class.md). |
| 65 | + |
| 66 | +You may also [add ActiveX controls to your dialog box](../windows/viewing-and-adding-activex-controls-to-a-dialog-box.md). |
| 67 | + |
| 68 | +You can also customize the **Toolbox** window for easier use. For more information, see [Using the Toolbox](/visualstudio/ide/using-the-toolbox). |
| 69 | + |
| 70 | +For more information on using the **RichEdit 1.0** control with MFC, see [Using the RichEdit 1.0 Control with MFC](../windows/using-the-richedit-1-0-control-with-mfc.md) |
| 71 | + |
| 72 | +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). |
| 73 | + |
| 74 | +## To add a control to a dialog box |
| 75 | + |
| 76 | +1. Ensure that the dialog box tabbed window is the current document in the editor frame. If a dialog isn't the current document, you won't see the **Dialog Editor Tab** in the **Toolbox**. |
| 77 | + |
| 78 | +1. On the **Dialog Editor** tab of the [Toolbox Window](/visualstudio/ide/reference/toolbox), select the control you want, then: |
| 79 | + |
| 80 | + - Select the dialog box at the location where you want to place the control. The control appears where you've selected. |
17 | 81 |
|
18 | 82 | \- or - |
19 | 83 |
|
20 | | - - Drag and drop the control from the **Toolbox** window to the location on your dialog box. For more information, see [Sizing a Control While You Add It](../windows/sizing-a-control-while-you-add-it.md). |
| 84 | + - Drag and drop the control from the **Toolbox** window to the location on your dialog box. |
21 | 85 |
|
22 | 86 | \- or - |
23 | 87 |
|
24 | 88 | - Double-click the control in the **Toolbox** window (it appears on your dialog box) then reposition the control to the location you prefer. |
25 | 89 |
|
26 | | -For information about the types of controls available on the **Toolbox** window, see [Dialog Editor Tab, Toolbox Window](../windows/dialog-editor-tab-toolbox.md). |
| 90 | +## To add multiple controls |
| 91 | + |
| 92 | +1. While holding down the **Ctrl** key, select a control in the [Toolbox Window](/visualstudio/ide/reference/toolbox). |
| 93 | + |
| 94 | +1. Release the **Ctrl** key and select the dialog box as many times as you want to add the particular control. |
| 95 | + |
| 96 | +1. Press **Esc** to stop placing controls. |
| 97 | + |
| 98 | +## To size a control while you add it |
| 99 | + |
| 100 | +1. Select a control in the [Toolbox Window](/visualstudio/ide/reference/toolbox). |
| 101 | + |
| 102 | +1. Place your cursor (which appears as cross hairs) where you want the upper-left corner of the new control to be on your dialog box. |
| 103 | + |
| 104 | +1. Select and hold down the mouse button to anchor the upper-left corner of your control on the dialog box, then drag the cursor to the right and down until the control is the size you want. |
| 105 | + |
| 106 | + > [!NOTE] |
| 107 | + > You can actually anchor any of the four corners of the control you're drawing. This procedure used the upper-left corner as an example. |
| 108 | +
|
| 109 | +1. Release the mouse button. The control settles onto the dialog box in the size you specified. |
27 | 110 |
|
28 | | -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). |
| 111 | + > [!TIP] |
| 112 | + > You can resize the control after dropping it onto the dialog box by moving the sizing handles on the border of the control. For more information, see [Sizing Individual Controls](../windows/sizing-individual-controls.md). |
29 | 113 |
|
30 | 114 | ## Requirements |
31 | 115 |
|
|
35 | 119 |
|
36 | 120 | [Controls in Dialog Boxes](../windows/controls-in-dialog-boxes.md)<br/> |
37 | 121 | [Adding Event Handlers for Dialog Box Controls](../windows/adding-event-handlers-for-dialog-box-controls.md)<br/> |
38 | | -[Dialog Box Controls and Variable Types](../ide/dialog-box-controls-and-variable-types.md) |
| 122 | +[Dialog Box Controls and Variable Types](../ide/dialog-box-controls-and-variable-types.md)<br/> |
| 123 | +[Controls](../mfc/controls-mfc.md)<br/> |
| 124 | +[Control Classes](../mfc/control-classes.md)<br/> |
| 125 | +[Dialog Box Classes](../mfc/dialog-box-classes.md)<br/> |
| 126 | +[Scroll-Bar Styles](../mfc/reference/styles-used-by-mfc.md#scroll-bar-styles)<br/> |
| 127 | +[Rich Edit Control Examples](../mfc/rich-edit-control-examples.md)<br/> |
0 commit comments