Adding Commands to the Add-in

If you work with a previously created add-in, you may want to add new commands.

To add a command to the add-in

  1. Open the add-in project.
  2. In ClassView, expand the project classes.
  3. Select the ICommands interface, and then right-click.
  4. Choose the Add Method command.
  5. In the Method Declaration field, enter the method that specifies what the command is supposed to do.
  6. In ClassView, expand the CCommands class, and then double-click the method name.
  7. In the Commands.cpp file, write the code for the method.
  8. In ClassView, expand the CPBAddIn class.
  9. Double-click the IDSAddIn::OnConnection method.
  10. Search for code that adds a command. This code calls the IApplication::AddCommand method.
  11. For the new command, copy and customize the AddCommand call.

Optionally, you can provide a toolbar button the user can press to carry out the command. If you used the Platform Builder Add-in Wizard and selected the Provides a Toolbar option, then the wizard generated the code needed to provide a button. However, if you did not select that option, you must add the necessary code.

As another option, you can create an image for the toolbar button. If you used the Platform Builder Add-in Wizard and selected the Provides a toolbar option, then the wizard automatically created an image for the button.

Finally, you can optionally assign a key sequence to the command.

See Also

New Commands and Toolbar Buttons | Creating Toolbar Buttons for Add-in Commands Programmatically | Creating Toolbar Buttons for Add-in Commands Visually

 Last updated on Friday, October 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.