|
1 | 1 | ---
|
2 | 2 | title: "Creating, Moving, and Editing Toolbar Buttons (C++)"
|
3 | 3 | ms.date: "11/04/2016"
|
4 |
| -helpviewer_keywords: ["buttons [C++], custom toolbars", "toolbar buttons [C++], editing", "buttons", "toolbar buttons [C++], creating"] |
| 4 | +f1_keywords: ["vc.editors.toolbar"] |
| 5 | +helpviewer_keywords: ["buttons [C++], custom toolbars", "toolbar buttons [C++], editing", "buttons", "toolbar buttons [C++], creating", "Toolbar editor [C++], creating buttons", "toolbar buttons [C++], button image", "toolbar buttons [C++], creating", "toolbar buttons (in Toolbar editor)", "toolbar buttons [C++], moving", "Toolbar editor [C++], moving buttons", "Toolbar editor [C++], copying buttons", "toolbars [C++], copying buttons", "toolbar buttons [C++], copying", "toolbar buttons [C++], deleting", "Toolbar editor [C++], deleting buttons", "Toolbar editor [C++], spacing toolbar buttons", "toolbar buttons [C++], space between buttons", "toolbar controls [MFC], command ID", "toolbar buttons [C++], setting properties", "Toolbar editor [C++], toolbar button properties", "command IDs, toolbar buttons", "size, toolbar buttons", "toolbar buttons [C++], setting properties", "Toolbar editor [C++], toolbar button properties", "status bars [C++], active toolbar button text", "command IDs, toolbar buttons", "width, toolbar buttons"] |
5 | 6 | ms.assetid: d0f0c6c6-9d7e-42b5-a86a-7558127386e7
|
6 | 7 | ---
|
7 |
| -# Creating, Moving, and Editing Toolbar Buttons |
| 8 | +# Creating, Moving, and Editing Toolbar Buttons (C++) |
8 | 9 |
|
9 | 10 | You can easily create, move, copy, and edit toolbar buttons.
|
10 | 11 |
|
11 |
| -By default, a new or blank button is displayed at the right end of the toolbar. You can move this button before editing it. When you create a new button, another blank button appears to the right of the edited button. When you save a toolbar, the blank button is not saved. |
| 12 | +By default, a new or blank button is displayed at the right end of the toolbar. You can move this button before editing it. When you create a new button, another blank button appears to the right of the edited button. When you save a toolbar, the blank button isn't saved. |
12 | 13 |
|
13 |
| -- [Create a new toolbar button](creating-a-new-toolbar-button.md) |
| 14 | +The properties of a toolbar button are: |
14 | 15 |
|
15 |
| -- [Move a toolbar button](moving-a-toolbar-button.md) |
| 16 | +|Property|Description| |
| 17 | +|--------------|-----------------| |
| 18 | +|**ID**|Defines the ID for the button. The drop-down list provides common **ID** names.| |
| 19 | +|**Width**|Sets the width of the button. 16 pixels is recommended.| |
| 20 | +|**Height**|Sets the height of the button. The height of one button changes the height of all buttons on the toolbar. 15 pixels is recommended.| |
| 21 | +|**Prompt**|Defines the message displayed in the status bar. Adding \n and a name adds a ToolTip to that toolbar button. For more information, see [Creating a ToolTip](../windows/creating-a-tool-tip-for-a-toolbar-button.md).| |
16 | 22 |
|
17 |
| -- [Copy buttons from a toolbar resource](../windows/copying-buttons-from-a-toolbar.md) |
| 23 | +**Width** and **Height** apply to all buttons. A bitmap that is used to create a toolbar has a maximum width of 2048. So if you set the button width to 512, you can only have four buttons and if you set the width to 513, you can only have three buttons. |
18 | 24 |
|
19 |
| -- [Delete a toolbar button](deleting-a-toolbar-button.md) |
| 25 | +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). |
20 | 26 |
|
21 |
| -- [Insert a space between buttons on a toolbar resource](../windows/inserting-a-space-between-buttons-on-a-toolbar.md) |
| 27 | +See the following actions: |
22 | 28 |
|
23 |
| -- [Close up a space between buttons on a toolbar](../windows/removing-space-between-buttons-on-a-toolbar.md) |
| 29 | +## To create a new toolbar button |
24 | 30 |
|
25 |
| -- [Edit the property page of a toolbar](../windows/changing-the-properties-of-a-toolbar-button.md) |
| 31 | +1. In [Resource view](../windows/resource-view-window.md) expand the resource folder (for example, *Project1.rc*). |
26 | 32 |
|
27 |
| -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). |
| 33 | + > [!NOTE] |
| 34 | + > 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). |
| 35 | +
|
| 36 | +1. Expand the **Toolbar** folder and select a toolbar to edit. |
| 37 | + |
| 38 | +1. Assign an ID to the blank button at the right end of the toolbar. You can do so by editing the **ID** property in the [Properties Window](/visualstudio/ide/reference/properties-window). For example, you may want to give a toolbar button the same ID as a menu option. In this case, use the drop-down list box to select the **ID** of the menu option. |
| 39 | + |
| 40 | + -or- |
| 41 | + |
| 42 | + Select the blank button at the right end of the toolbar (in the **Toolbar View** pane) and begin drawing. A default button command ID is assigned (ID_BUTTON\<n>). |
| 43 | + |
| 44 | +You can also copy and paste an image onto a toolbar as a new button. |
| 45 | + |
| 46 | +## To add an image to a toolbar as a button |
| 47 | + |
| 48 | +1. In [Resource View](../windows/resource-view-window.md), open the toolbar by double-clicking it. |
| 49 | + |
| 50 | +1. Next, open the image you'd like to add to your toolbar. |
| 51 | + |
| 52 | + > [!NOTE] |
| 53 | + > If you open the image in Visual Studio, it will open in the **Image** editor. You can also open the image in other graphics programs. |
| 54 | +
|
| 55 | +1. From the **Edit** menu, choose **Copy**. |
| 56 | + |
| 57 | +1. Switch to your toolbar by selecting its tab at the top of the source window. |
| 58 | + |
| 59 | +1. From the **Edit** menu, choose **Paste**. |
| 60 | + |
| 61 | + The image will appear on your toolbar as a new button. |
| 62 | + |
| 63 | +## To move a toolbar button |
| 64 | + |
| 65 | +In the **Toolbar View** pane, drag the button that you want to move to its new location on the toolbar. |
| 66 | + |
| 67 | +## To copy buttons from a toolbar |
| 68 | + |
| 69 | +1. Hold down the **Ctrl** key. |
| 70 | + |
| 71 | +1. In the **Toolbar View** pane, drag the button to either its new location on the toolbar or to a location on another toolbar. |
| 72 | + |
| 73 | +## To delete a toolbar button |
| 74 | + |
| 75 | +Select the toolbar button and drag it off the toolbar. |
| 76 | + |
| 77 | +## To insert or remove space between buttons on a toolbar |
| 78 | + |
| 79 | +In general, to insert a space between buttons, drag them away from one another on the toolbar. To remove space, drag them towards each other. |
| 80 | + |
| 81 | +### To insert a space before a button that isn't followed by a space |
| 82 | + |
| 83 | +Drag the button to the right or down until it overlaps the next button about halfway. |
| 84 | + |
| 85 | +### To insert a space before a button that is followed by a space and to keep the trailing space |
| 86 | + |
| 87 | +Drag the button until the right or bottom edge is just touching the next button or just overlaps it. |
| 88 | + |
| 89 | +### To insert a space before a button that is followed by a space and close up that following space |
| 90 | + |
| 91 | +Drag the button to the right or down until it overlaps the next button about halfway. |
| 92 | + |
| 93 | +### To remove a space between buttons on a toolbar |
| 94 | + |
| 95 | +Drag the button on one side of the space toward the button on the other side of the space until it overlaps the next button about halfway. |
| 96 | + |
| 97 | + If there's no space on the side of the button that you're dragging away from, and you drag the button more than halfway past the adjacent button, the **Toolbar** editor also inserts a space on the opposite side of the button that you're dragging. |
| 98 | + |
| 99 | +## To change the properties of a toolbar button |
| 100 | + |
| 101 | +1. In a C++ project, select the toolbar button. |
| 102 | + |
| 103 | +1. Type the new ID in the **ID** property in the [Properties Window](/visualstudio/ide/reference/properties-window), or use the drop-down list to select a new **ID**. |
28 | 104 |
|
29 | 105 | ## Requirements
|
30 | 106 |
|
31 | 107 | MFC or ATL
|
32 | 108 |
|
33 | 109 | ## See Also
|
34 | 110 |
|
35 |
| -[Toolbar Editor](../windows/toolbar-editor.md) |
| 111 | +[Toolbar Editor](../windows/toolbar-editor.md) |
0 commit comments