Adding a SubMenu Component to Visual Studio Node

How to add menu items and submenus when you right-click on Explorer to view visual Studio files?

I have one menu and three submenu items that will be displayed when I right-click on a file in the solution explorer, as shown in the figure below.

I tried using the .vsct buttons, but it will appear in the context menu, and Iam will not be able to add a submenu

enter image description here

+8
visual-studio-2012 visual-studio-extensions
source share
1 answer

Creating VSCT files VSCT somewhat difficult; You will need a combination of menus and buttons. First of all, you need to specify the IDM_VS_CTXT_ITEMNODE group in your VSCT file.

 <Group guid="guidCmdSet" id="grpIdMenuProjectItem" priority="0x0800"> <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE" /> </Group> 

How do you create a new menu and add it to this group ...

  <Menu guid="guidCmdSet" id="sampleMenu" type="Menu" priority="0x1000"> <Parent guid="guidCmdSet" id="grpIdMenuProjectItem" /> <CommandFlag>IconAndText</CommandFlag> <Strings> <ButtonText>Sample Menu</ButtonText> <CommandName>Sample Menu</CommandName> </Strings> </Menu> 

For submenu items, another group is required, which will be added to the menu ...

 <Group guid="guidCmdSet" id="sampleMenuGroup" priority="0x1000"> <Parent guid="guidCmdSet" id="sampleMenu"/> </Group> 

At least you define the submenu items using the buttons and add them to the submenu group ...

 <Button guid="guidCmdSet" id="sampleMenuItem" priority="0x1000" type="Button"> <Parent guid="guidCmdSet" id="sampleMenuGroup"/> <CommandFlag>TextOnly</CommandFlag> <Strings> <ButtonText>Sample Menu Item 1</ButtonText> <CommandName>sampleMenuItem1</CommandName> </Strings> </Button> 

Remember to define all characters, otherwise the resource will not compile.

 <IDSymbol name="grpIdMenuProjectItem" value="0x1020"/> <IDSymbol name="sampleMenu" value="0x1021"/> <IDSymbol name="sampleMenuGroup" value="0x1022"/> <IDSymbol name="sampleMenuItem" value="0x1023"/> 

And here is what you get ...

enter image description here

+25
source share

All Articles