
408
|
Chapter 12, Extending Visual Studio
#90 Find the Name of That Command Bar
HACK
is the right-click menu. To create a new command and assign it to a com-
mand bar, you will use code that looks like the following:
Command command = commands.AddNamedCommand(addInInstance,
"Add-IN", "Command", "Executes the command for this Add-in",
true, 59, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatus.vsCommandStatusEnabled);
CommandBar commandBar = (CommandBar)commandBars["Tools"];
CommandBarControl commandBarControl =
command.AddControl(commandBar, 1);
The preceding code would add a new command to the Tools menu. As you
can see, there is a collection named
commandBars that you use to specify
which
CommandBar you want to add your command to. The problem is that
there is no easy way to find out what these names are in Visual Studio.
Thankfully, there is a way to get a list of all these
CommandBars using a free
download from Microsoft.
Install the Command Browser
The add-in you can use to view the names of the different command bars is
actually part of the automation samples. To download this add-in, go to:
http://www.microsoft.com/downloads/details.aspx?familyid=3ff9c915-
30e5-430e-95b3-621dccd25150&displaylang=en#filelist
Choose the Command Browser Add-in from the list of files (CmdBrowser.
exe). Download this file and then extract its contents to a directory on your
hard ...