Of course, there are similiar questions, but this seems to be a special case...
In general, you need to know the menu´s command- and package id that you want to extend. I usually do this by enabling the EnableVSIPLogging
option in the registry as described by this article:
http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx. The EnableVSIPLogging
option was introduced with Visual Studio 2005, but still works in any newer version.
Once the EnableVSIPLogging
option is enabled, you can display the wanted information by clicking on a menu item (or any other UI element that is interconnected with a command) while pressing Ctrl+Shift. This will show a message box containing the package guid and command/menu id; Ctrl+C copies the shown menu- or command- data to the clipboard, btw. If you´re interested in menu data (in case it´s a context menu, press Ctrl+Shift before hovering the item).
This is what I got on my machine...
---------------------------
VSDebug Message
---------------------------
Menu data:
Guid = {D309F791-903F-11D0-9EFC-00A0C911004F}
GuidID = 4
CmdID = 850
Type = 0x00000100
Flags = 0x00000000
NameLoc = A&dd
---------------------------
OK
---------------------------
The menu information can than be used in authoring your VSCT
file; this question might be of your interest: Using vsx how do you create a sub menu with commands?
While reading the other question´s answer, you may wonder how these guys figured the names for the command guids... those names are defined by the vsshlids.h
header file, which is included with the Visual Studio SDK. So, for the guid shown above we find...
// Guid for Shell's group and menu ids
DEFINE_GUID (guidSHLMainMenu,
0xd309f791, 0x903f, 0x11d0, 0x9e, 0xfc, 0x00, 0xa0, 0xc9, 0x11, 0x00, 0x4f);
We can use guidSHLMainMenu
for the group definition...
<Group guid="your-command-set" id="your-group-id">
<Parent guid="guidSHLMainMenu" id="..." />
</Group>
I expected to find a IDM_VS_CTXT_
constant (or something similiar) in vsshlids.h
that matches the command id, but nope... Instead I found cmdidShellWindowNavigate7
and cmdidShellWindowNavigate5
constants in stdidcmd.h
; and just tried them out...
First I created new id-symbols for two command groups...
<IDSymbol name="grpIdProjectContextAdd" value="0x1080" />
<IDSymbol name="grpIdSolutionContextAdd" value="0x1081" />
And a command...
<IDSymbol name="cmdIdAddItemHelloWorld" value="0x1082" />
Than I defined new groups; and used the obtained command identifiers as parent...
<Groups>
<Group guid="your-command-set" id="grpIdProjectContextAdd">
<Parent guid="guidSHLMainMenu" id="cmdidShellWindowNavigate7" />
</Group>
<Group guid="your-command-set" id="grpIdSolutionContextAdd">
<Parent guid="guidSHLMainMenu" id="cmdidShellWindowNavigate5" />
</Group>
</Groups>
Of course, I need a button (which is placed in the Add
menu of the project by default).
<Commands>
<Button guid="your-command-set"
id="cmdIdAddItemHelloWorld" priority="0x1100" type="Button">
<Parent guid="your-command-set" id="grpIdProjectContextAdd" />
<Strings>
<ButtonText>Hello World</ButtonText>
</Strings>
</Button>
</Commands>
To make the button also appear in the Add
menu of the solution node, I use a command placement...
<CommandPlacements>
<CommandPlacement guid="your-command-set"
id="cmdIdAddItemHelloWorld" priority="0x1100">
<Parent guid="your-command-set" id="grpIdSolutionContextAdd" />
</CommandPlacement>
</CommandPlacements>
For me, it feels a bit hacky to use the cmdidShellWindowNavigate7
and cmdidShellWindowNavigate5
constants, but in the result I got this...