
414
|
Chapter 12, Extending Visual Studio
#91 Change the Icon for Your Add-in
HACK
Modify Command Code
The default code to add a command created by the Add-in Wizard is shown
here:
Command command = commands.AddNamedCommand(addInInstance,
"TryCatchMatic", "TryCatchMatic", "Surround W/ Try..Catch",
true, 59, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported
+(int)vsCommandStatus.vsCommandStatusEnabled);
The Boolean value here represents whether the icon you are using is a
Microsoft icon or a custom icon. You will need to change this to false and
then replace the number 59 with the ID of your bitmap. (This is usually 101,
but you can check by double-clicking on your assembly in Visual Studio and
expanding the folder named Bitmap). Here is the new line of code:
Command command = commands.AddNamedCommand(addInInstance,
"TryCatchMatic", "TryCatchMatic", "Surround W/ Try..Catch",
false, 101, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported
+(int)vsCommandStatus.vsCommandStatusEnabled);
This command will now try to use the bitmap with the ID 101 in your new
assembly.
You could alternatively set the icon to another of the default icons. You
could do this by leaving the Boolean value set to true and then specifying
another number instead of 59. To view a list of all the available icons, you
can use a small utility available from http://www.visualstudiohacks.com/
iconspy.
Add to Installer ...