Share via


Creating a New Toolbar Button

To create a new toolbar button

  1. In Resource view expand the resource folder (for example, Project1.rc).

    Note

    If your project doesn't already contain an .rc file, please see Creating a New Resource Script File.

  2. Expand the Toolbar folder and select a toolbar to edit.

  3. 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. 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.

    –or–

    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>).

You can also copy and paste an image onto a toolbar as a new button.

To add an image to a toolbar as a button

  1. In Resource View, open the toolbar by double-clicking it.

  2. Next, open the image you'd like to add to your toolbar.

    Note

    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.

  3. From the Edit menu, choose Copy.

  4. Switch to your toolbar by clicking its tab at the top of the source window.

  5. From the Edit menu, choose Paste.

    The image will appear on your toolbar as a new button.

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.

Requirements

MFC or ATL

See Also

Reference

Toolbar Button Properties

Creating, Moving, and Editing Toolbar Buttons

Toolbar Editor