1

I am trying to add a menu item in the Tools menu (using IDM_VS_MENU_TOOLS) which is having two child menu buttons. But not able to do it. But if I add the same with IDG_VS_MM_TOOLSADDINS as a top-level menu then I am able to see it inside Extensions menu which is fine (Follow img-1).

img-1 img-1

As per the image, I want to add My Top Menu (with its sub commands) into Tools menu. How can I do that? I tried following code but nothing changes but My Top Menu also removed.

<?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"/>

  <Commands package="guidMultipleMenuCmdTestPackage">
    <Groups>
      <Group guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop" priority="0x0600">

      </Group>
    </Groups>

    <Menus>
      <Menu guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroup" type="Menu" priority="0x0600">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
        <Strings>
          <ButtonText>My Top Menu</ButtonText>
        </Strings>
      </Menu>
    </Menus>

    <Buttons>
      <Button guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command1Id" type="Button">
        <Strings>
          <ButtonText>Changed 2</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command2Id" type="Button">
        <Strings>
          <ButtonText>Command 2</ButtonText>
        </Strings>
      </Button>
    </Buttons>

    <Bitmaps>
      <Bitmap guid="guidImages" href="Resources\Ext1.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
    </Bitmaps>

  </Commands>

  <CommandPlacements>

    <CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop" priority="0x0601">
      <Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroup"/>
    </CommandPlacement>

    <CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command1Id" priority="0x0601" >
      <Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop"/>
    </CommandPlacement>
    <CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command2Id" priority="0x0602" >
      <Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop"/>
    </CommandPlacement>
  </CommandPlacements>

  <Symbols>
    <GuidSymbol name="guidMultipleMenuCmdTestPackage" value="{5f20b1ae-835b-423f-89e1-a33f2e20a715}" />

    <GuidSymbol name="guidMultipleMenuCmdTestPackageCmdSet" value="{2e60374a-c4f8-4d96-9bb6-301ab412846f}">
      <IDSymbol name="MyMenuGroup" value="0x1020" />
      <IDSymbol name="MyMenuGroupTop" value="0x1021" />
      <IDSymbol name="Command1Id" value="0x0101" />
      <IDSymbol name="Command2Id" value="0x0102" />
    </GuidSymbol>

    <GuidSymbol name="guidImages" value="{512d3770-bde4-4353-a6c0-7138bbfffebe}" >
      <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" />
      <IDSymbol name="bmpPicStrikethrough" value="6" />
    </GuidSymbol>
  </Symbols>
</CommandTable>


More Information (Edited):-

When I replace <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/> from Menu tag to Group tag and then run, I can see the sub commands only under Tools menu. (Please reffer to img-2)

img-2 img-2

Tanmay Bairagi
  • 564
  • 5
  • 25

2 Answers2

2

This is the new behavior of Visual Studio 2019. You can't insert custom options anymore outside of the Extensions section of that menu. If you build your extension for VS 2015 and 2017 too, then you can add your new options in the Tools section or you can create a new entry in the top menu near Tools.

Keep in mind that the Extension section doesn't exist in VS 2015 and 2017

Ionut Enache
  • 461
  • 8
  • 22
2

I referred this answer. Here I got the clue to solving my problem. I just added another group and made few changes as I required to add reference to the group. Following is the code that provided me a perfect solution :

<?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"/>

  <Commands package="guidCodeReviewMainPackage">

    <Groups>
      <Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup" priority="0x0600">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
      </Group>
      <Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" priority="0x0600">
        <Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem"/>
      </Group>
    </Groups>

    <Menus>
      <Menu guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem" type="Menu" priority="0x0600">
        <Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup"/>
        <Strings>
          <ButtonText>Caladrius</ButtonText>
        </Strings>
      </Menu>
    </Menus>

    <Buttons>
      <Button guid="guidCodeReviewMainPackageCmdSet" id="Ext1Id" priority="0x0100" type="Button">
        <Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
        <Strings>
          <ButtonText>Select Directories</ButtonText>
        </Strings>
      </Button>

      <Button guid="guidCodeReviewMainPackageCmdSet" id="Ext2Id" priority="0x0101" type="Button">
        <Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
        <Icon guid="guidImages" id="bmpPic1" />
        <Strings>
          <ButtonText>Load Recent</ButtonText>
        </Strings>
      </Button>
    </Buttons>

    <Bitmaps>
      <Bitmap guid="guidImages" href="Resources\Ext1.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
    </Bitmaps>
  </Commands>

  <Symbols>
    <GuidSymbol name="guidCodeReviewMainPackage" value="{-----}" />

    <GuidSymbol name="guidCodeReviewMainPackageCmdSet" value="{-----}">
      <IDSymbol name="MyMenuGroup" value="0x1021" />
      <IDSymbol name="MyMenuItem" value="0x1020" />
      <IDSymbol name="MyMenuSubGroup" value="0x1022" />
      <IDSymbol name="Ext1Id" value="0x0100" />
      <IDSymbol name="Ext2Id" value="0x0101" />
    </GuidSymbol>

    <GuidSymbol name="guidImages" value="{a0eaa6e3-70cc-45c8-9300-1bedd0871fe6}" >
      <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" />
      <IDSymbol name="bmpPicStrikethrough" value="6" />
    </GuidSymbol>
  </Symbols>
</CommandTable>

Tanmay Bairagi
  • 564
  • 5
  • 25