How can I add a sub menu for the Add menu item when right click on a visual studio solution explorer?
I have to add a single sub menu item which will be displayed n right clicking the visual studio solution and move to the Add option in that menu.
I am trying using .vsct (vs package). Please help me with valuable suggestions
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. TheEnableVSIPLogging
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...
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...We can use
guidSHLMainMenu
for the group definition...I expected to find a
IDM_VS_CTXT_
constant (or something similiar) invsshlids.h
that matches the command id, but nope... Instead I foundcmdidShellWindowNavigate7
andcmdidShellWindowNavigate5
constants instdidcmd.h
; and just tried them out...First I created new id-symbols for two command groups...
And a command...
Than I defined new groups; and used the obtained command identifiers as parent...
Of course, I need a button (which is placed in the
Add
menu of the project by default).To make the button also appear in the
Add
menu of the solution node, I use a command placement...For me, it feels a bit hacky to use the
cmdidShellWindowNavigate7
andcmdidShellWindowNavigate5
constants, but in the result I got this...