Skip to Main Content
Visual Studio Hacks
book

Visual Studio Hacks

by James Avery
March 2005
Intermediate to advanced content levelIntermediate to advanced
304 pages
19h 23m
English
O'Reilly Media, Inc.
Content preview from Visual Studio Hacks
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft Visual Studio 2015 Unleashed, Third Edition

Microsoft Visual Studio 2015 Unleashed, Third Edition

Mike Snell, Lars Powers
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 0596008473Errata Page