在Visual Studio工具菜单中创建多级子菜单

问题描述 投票:0回答:1

在Visual Studio工具菜单中创建多级子菜单

我想在Visual Studio工具菜单中创建一个多级菜单。

我希望看到的结构如下所示。

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

从.vsct文件中的以下代码,我可以进入如下结构

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

如何在GC菜单中添加子菜单“Licenses”并为其添加Activate / Deactivate按钮?

<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个回答
0
投票

我们将只需添加更多组并设置其优先级,即可创建多级菜单,如下所示。

<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>
© www.soinside.com 2019 - 2024. All rights reserved.