locked
How to use standard VS commands in custom menu (vsct) RRS feed

  • Question

  • Hi,

    I have a .vsct file which defines a custom menu. I want to add some default Visual Studio commands to this menu as well. I already managed to add some default commands such as copy / paste:

    <UsedCommands>
        <UsedCommand guid="guidVSStd97" id="cmdidCopy"/>
    </UsedCommands>
    
    <CommandPlacements>
        <CommandPlacement guid="guidVSStd97" id="cmdidCopy" priority="0x0100">
            <Parent guid="guidMyMenuCommands" id="grpMyMenu"/>
        </CommandPlacement>
    </CommandPlacements>

    When I do this, the "Copy" command shows up in my custom menu, with default Icon, text and shortcut - just as it should be. However, this does not work for all commands. To be precise, when I want to add the following commands...

    <UsedCommand guid="guidVSStd2K" id="ECMD_FORMATDOCUMENT"/>
    <UsedCommand guid="guidVSStd2K" id="ECMD_COMMENT_BLOCK"/>
    <UsedCommand guid="guidVSStd2K" id="ECMD_UNCOMMENT_BLOCK"/>

    ...nothing happens - no entry is added to my custom menu. How can I include the above default commands in a custom menu?

    Thanks,
    Max


    Wednesday, February 25, 2015 8:28 AM

Answers

  • I just found out that the above commands are there after all, but they are invisible until a source code file is opened. I expected them to be grayed out instead of being totally invisible.

    Nevertheless, there are some commands that cannot be "instantiated" with the CommandPlacement tag. Instead, one needs to create a button for the respective command to show up in the menu. The following code shows an example:

    <UsedCommands>
      <UsedCommand guid="guidVSStd97" id="cmdidGotoDefn" />
    </UsedCommands>
    
    <Commands>
      <Buttons>
        <Button guid="guidVSStd97" id="cmdidGotoDefn" priority="0x0400">
          <Parent guid="guidMyMenuCommands" id="grpMyMenu" />
          <Strings>
            <ButtonText></ButtonText>
          </Strings>
        </Button>
      </Buttons>
    </Commands>




    • Marked as answer by f_max Wednesday, February 25, 2015 10:42 AM
    • Edited by f_max Wednesday, February 25, 2015 10:44 AM
    Wednesday, February 25, 2015 10:42 AM

All replies

  • I just found out that the above commands are there after all, but they are invisible until a source code file is opened. I expected them to be grayed out instead of being totally invisible.

    Nevertheless, there are some commands that cannot be "instantiated" with the CommandPlacement tag. Instead, one needs to create a button for the respective command to show up in the menu. The following code shows an example:

    <UsedCommands>
      <UsedCommand guid="guidVSStd97" id="cmdidGotoDefn" />
    </UsedCommands>
    
    <Commands>
      <Buttons>
        <Button guid="guidVSStd97" id="cmdidGotoDefn" priority="0x0400">
          <Parent guid="guidMyMenuCommands" id="grpMyMenu" />
          <Strings>
            <ButtonText></ButtonText>
          </Strings>
        </Button>
      </Buttons>
    </Commands>




    • Marked as answer by f_max Wednesday, February 25, 2015 10:42 AM
    • Edited by f_max Wednesday, February 25, 2015 10:44 AM
    Wednesday, February 25, 2015 10:42 AM
  • Thank you for sharing your solution here.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 26, 2015 10:05 AM