Adding Commands to the Visual C++ Developer Studio
Home Page (Add-ins) | Overview | How Do I ... Topics | FAQ | Reference
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
-
Open the add-in's project.
-
In ClassView, expand the project's classes.
-
Select the ICommands interface, and then click the right mouse button.
-
Click the Add Method command.
-
In the Method Declaration box, enter the method that specifies what the command is supposed to do.
-
In ClassView, expand the CCommands class, and then double-click the method name.
-
In the Commands.cpp file, write the code for the method.
-
In ClassView, expand the CDSAddIn class.
-
Double-click the OnConnection method.
-
Search for code that adds a command. This code calls the AddCommand method.
-
For the new command, copy and customize the AddCommand call.
-
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.
-
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.
-
Optionally, assign a key sequence to the command. For details, see Assigning Key Sequences to Add-in Commands_Programmatically.