Adding Commands to the Visual C++ Developer Studio

Home Page (Add-ins)OverviewHow Do I ... TopicsFAQReference

If you use the Developer Studio Add-in Wizard to create an add-in, the wizard automatically creates the code for adding one command to the Visual C++ environment. However, if you want to add other commands, you must write additional code.

To add a command

  1. Open the add-in's project.

  2. In ClassView, expand the project's classes.

  3. Select the ICommands interface, and then click the right mouse button.

  4. Click the Add Method command.

  5. In the MethodDeclaration box, 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 CDSAddIn class.

  9. Double-click the OnConnection method.

  10. Search for code that adds a command. This code calls the AddCommand method.

  11. For the new command, copy and customize the AddCommand call.

  12. Optionally, provide a toolbar button the user can press to carry out the command. If you used the Developer Studio Add-in Wizard and selected the Provides a toolbar option, then the wizard generated the code needed to provide a button. However, if you didn't select that option, you must add the necessary code. For details, see Creating Toolbar Buttons for Add-in Commands Programmatically.

  13. Optionally, create an image for the toolbar button. If you used the Developer Studio Add-in Wizard and selected the Provides a toolbar option, then the wizard automatically created an image for the button. For details, see Creating Images for Toolbar Buttons.

  14. Optionally, assign a key sequence to the command. For details, see Assigning Key Sequences to Add-in Commands_Programmatically.