Create a multilevel submenu in Visual Studio Tools

2019-08-31 14:41发布

Create a multilevel submenu in Visual Studio Tools menu

I am looking to create a multilevel menu within the Visual Studio Tools menu.

I would want the structure as seen to be something like below.

    Tools
         |->GC
              |->Licenses--------------------------->|
              |->Samples                             |-> Activate
                                                     |-> Deactivate

From the below code in the .vsct file, I am able to get to the structure as below

    Tools|
         |->GC->|
                |->Licenses
                |->Samples.

How would I be able to add a submenu "Licenses" into the GC menu and add the Activate/Deactivate buttons to it?

<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidComponentOneMenuPackage">
<Menus>
<Menu guid="guidComponentOneMenuPackageCmdSet" id="TopLevelMenu" priority="0x700" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDG_VS_TOOLS_EXT_TOOLS" />
<Strings>
<ButtonText>GC</ButtonText>
<CommandName>GC</CommandName>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="guidComponentOneMenuPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="TopLevelMenu"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidComponentOneMenuPackageCmdSet" id="LicenseManagerId" priority="0x0100" type="Button">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Licenses</ButtonText>
</Strings>
</Button>
<Button guid="guidComponentOneMenuPackageCmdSet" id="SamplesExplorerId" priority="0x0101" type="Button">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Samples</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\GC.png" usedList="bmpPic1"/>
</Bitmaps>
</Commands>
<Symbols>
<GuidSymbol name="guidComponentOneMenuPackage" value="{458b53ac-7a4e-440d-aebf-d3eec4fd24e2}" />
<GuidSymbol name="guidComponentOneMenuPackageCmdSet" value="{d2b0b608-ab47-47c6-a9a3-d0cf3b64157b}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="LicenseManagerId" value="0x0100" />
<IDSymbol name="SamplesExplorerId" value="0x0101" />
<IDSymbol name="TopLevelMenu" value="0x1021"/>
</GuidSymbol>
<GuidSymbol name="guidImages" value="{6e5edeb3-274c-4147-a06d-7f50f10160b9}" >
<IDSymbol name="bmpPic1" value="1" />
</GuidSymbol>
</Symbols>
</CommandTable>

标签: vspackage
1条回答
forever°为你锁心
2楼-- · 2019-08-31 15:45

We will be able to create multilevel menus by merely adding more groups and setting their priority as below.

<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18  /CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidComponentOneMenuPackage">
<Menus>
<Menu guid="guidComponentOneMenuPackageCmdSet" id="TopLevelMenu" priority="0x700" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDG_VS_TOOLS_EXT_TOOLS" />
<Strings>
<ButtonText>GC</ButtonText>
<CommandName>GC</CommandName>
</Strings>
</Menu>
<Menu guid="guidComponentOneMenuPackageCmdSet" id="GCMenu" priority="0x0200" type="Menu">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="MyMenuGroup" />
<Strings>
<ButtonText>Main</ButtonText>
<CommandName>Main</CommandName>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="guidComponentOneMenuPackageCmdSet" id="GCGroup" priority="0x0600">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="GCMenu"/>
</Group>
<Group guid="guidComponentOneMenuPackageCmdSet" id="MyMenuGroup"   priority="0x0600">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="TopLevelMenu"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidComponentOneMenuPackageCmdSet" id="LicenseManagerId" priority="0x0201" type="Button">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="GCGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Licenses</ButtonText>
</Strings>
</Button>
<Button guid="guidComponentOneMenuPackageCmdSet" id="SamplesExplorerId" priority="0x0202" type="Button">
<Parent guid="guidComponentOneMenuPackageCmdSet" id="GCGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Samples</ButtonText>
</Strings>
</Button>
</Buttons>  
<Bitmaps>
</Bitmaps>
</Commands>
<Symbols>
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="GCGroup" value="0x0202" />
<IDSymbol name="LicenseManagerId" value="0x0100" />
<IDSymbol name="SamplesExplorerId" value="0x0101" />
<IDSymbol name="TopLevelMenu" value="0x1021"/>
<IDSymbol name="GCMenu" value="0x1022"/>
</GuidSymbol>
</Symbols>
</CommandTable>
查看更多
登录 后发表回答