使用 vsx 如何使用命令创建子菜单?

发布于 2024-08-29 03:16:19 字数 3078 浏览 1 评论 0原文

我创建了以下 vsct 文件 xml。

<?xml version="1.0" encoding="utf-8"?>
<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"/>
    <Extern href="msobtnid.h"/>
    <Commands package="guidMyVSXCommandsPkg">
        <Menus>
            <Menu guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu" priority="0x100" type="Menu">
                <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
                <Strings>
                    <MenuText>Work???</MenuText>
                    <ButtonText>FigureMain</ButtonText>
                    <CommandName>TryMainMenu</CommandName>
                </Strings>
            </Menu>
        </Menus>
        <Groups>
            <Group guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" priority="0x0600">
                <Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu"/>
            </Group>
        </Groups>
        <Buttons>
            <Button guid="guidMyVSXCommandsCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">
                <Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" />
                <Icon guid="guidImages" id="bmpPic1" />
                <Strings>
                    <CommandName>cmdidMyCommand</CommandName>
                    <ButtonText>DO SOMETHING REAL COOL!!!!!!!!</ButtonText>
                </Strings>
            </Button>
        </Buttons>
        <Bitmaps>
            <Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
        </Bitmaps>
    </Commands>
    <Symbols>
        <!-- This is the package guid. -->
        <GuidSymbol name="guidMyVSXCommandsPkg" value="{70e6574c-ebed-4856-b78b-0927966cc800}" />

        <!-- This is the guid used to group the menu commands together -->
        <GuidSymbol name="guidMyVSXCommandsCmdSet" value="{301c910a-65eb-42c4-bf0f-bc5aaac737f1}">
            <IDSymbol name="TopLevelMenu" value="0x0100" />
            <IDSymbol name="TopLevelMenuGroup" value="0x0200" />
            <IDSymbol name="cmdidMyCommand" value="0x0300" />
        </GuidSymbol>
        <GuidSymbol name="guidImages" value="{1997bf57-349c-434a-ad64-32a3a65e35f3}" >
            <IDSymbol name="bmpPic1" value="1" />
            <IDSymbol name="bmpPic2" value="2" />
            <IDSymbol name="bmpPicSearch" value="3" />
            <IDSymbol name="bmpPicX" value="4" />
            <IDSymbol name="bmpPicArrows" value="5" />
        </GuidSymbol>
    </Symbols>

</CommandTable>

当我的上下文菜单中有“

工作”选项时,我想看到的最终结果是什么??? -->做一些真正酷的事情!!!!!!!!!

I have created the following vsct file xml.

<?xml version="1.0" encoding="utf-8"?>
<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"/>
    <Extern href="msobtnid.h"/>
    <Commands package="guidMyVSXCommandsPkg">
        <Menus>
            <Menu guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu" priority="0x100" type="Menu">
                <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
                <Strings>
                    <MenuText>Work???</MenuText>
                    <ButtonText>FigureMain</ButtonText>
                    <CommandName>TryMainMenu</CommandName>
                </Strings>
            </Menu>
        </Menus>
        <Groups>
            <Group guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" priority="0x0600">
                <Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu"/>
            </Group>
        </Groups>
        <Buttons>
            <Button guid="guidMyVSXCommandsCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">
                <Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" />
                <Icon guid="guidImages" id="bmpPic1" />
                <Strings>
                    <CommandName>cmdidMyCommand</CommandName>
                    <ButtonText>DO SOMETHING REAL COOL!!!!!!!!</ButtonText>
                </Strings>
            </Button>
        </Buttons>
        <Bitmaps>
            <Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
        </Bitmaps>
    </Commands>
    <Symbols>
        <!-- This is the package guid. -->
        <GuidSymbol name="guidMyVSXCommandsPkg" value="{70e6574c-ebed-4856-b78b-0927966cc800}" />

        <!-- This is the guid used to group the menu commands together -->
        <GuidSymbol name="guidMyVSXCommandsCmdSet" value="{301c910a-65eb-42c4-bf0f-bc5aaac737f1}">
            <IDSymbol name="TopLevelMenu" value="0x0100" />
            <IDSymbol name="TopLevelMenuGroup" value="0x0200" />
            <IDSymbol name="cmdidMyCommand" value="0x0300" />
        </GuidSymbol>
        <GuidSymbol name="guidImages" value="{1997bf57-349c-434a-ad64-32a3a65e35f3}" >
            <IDSymbol name="bmpPic1" value="1" />
            <IDSymbol name="bmpPic2" value="2" />
            <IDSymbol name="bmpPicSearch" value="3" />
            <IDSymbol name="bmpPicX" value="4" />
            <IDSymbol name="bmpPicArrows" value="5" />
        </GuidSymbol>
    </Symbols>

</CommandTable>

What the end result is I want to see when I the context menu to have an option of

Work??? --> DO SOMETHING REAL COOL!!!!!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江心雾 2024-09-05 03:16:19

您的菜单应将其父级设置为,而不是顶级上下文菜单。例如,尝试将此行:更改为此

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>

行:

<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_START"/>

您现在应该看到“TryMainMenu”显示在项目节点的上下文菜单上的“Debug”旁边。如果您希望菜单存在于顶级上下文菜单上自己的组中,则应定义一个具有父级 IDM_VS_CTXT_PROJNODE 的新组,并将菜单的父级设置为该组。

或者,您可以通过查看 SharedCmdPlace.vsct 并查找具有以下父级的 Group 元素来发现其他现有组(IDG_VS_CTXT_PROJECT_START 除外):

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>

Your Menu should have its parent set to a group instead of the top-level context menu. For example, try changing this line:

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>

to this line:

<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_START"/>

You should now see "TryMainMenu" show up next to "Debug" on the project node's context menu. If you want your menu to exist in its own group on the top level context menu, you should define a new group with parent IDM_VS_CTXT_PROJNODE and set your menu's parent to that.

Alternatively, you can discover what the other existing groups are (besides IDG_VS_CTXT_PROJECT_START) by looking at SharedCmdPlace.vsct and finding Group elements with the following parent:

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文