none
How to add a menu item to the File Tab context menu in a VSIX package? RRS feed

  • Question

  • I'd like to add a menu item for the context menu which appears for the File tab in Visual Studio 2013 (the one that has items like Close All Documents, Copy Full Path, Open Containing Folder, etc).

    I have a VSIX project, and would assume that all I need to do is to get the right service (via GetService). But I have no idea what the name of the correct service is.

    Friday, March 20, 2015 5:34 PM

Answers

  • Hi,

    Adding a menu item has nothing to do with getting the right service. Instead:

    - Create a new package with the package wizard selecting the menu command checkbox.

    - In the generated .vsct file of the project, change the parent of the "MyMenuGroup" from IDM_VS_MENU_TOOLS to IDM_VS_CTXT_EZDOCWINTAB:

          <Group guid="guidVSPackage3CmdSet" id="MyMenuGroup" priority="0x0600">

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

             <!--

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

             -->

          </Group>


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Friday, March 20, 2015 7:18 PM
    Moderator

All replies

  • Hi,

    Adding a menu item has nothing to do with getting the right service. Instead:

    - Create a new package with the package wizard selecting the menu command checkbox.

    - In the generated .vsct file of the project, change the parent of the "MyMenuGroup" from IDM_VS_MENU_TOOLS to IDM_VS_CTXT_EZDOCWINTAB:

          <Group guid="guidVSPackage3CmdSet" id="MyMenuGroup" priority="0x0600">

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

             <!--

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

             -->

          </Group>


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Friday, March 20, 2015 7:18 PM
    Moderator
  • Perfect. Thanks.
    Monday, March 23, 2015 5:14 PM
  • I have to admit, I thought that once the menu item was added to the menu, that it would have context for the context menu it was getting called on.

    Any hints on how to get the path to the file that the context menu is being opened on?

    In the MenuItemCallback neither the sender, nor the event args have any contextual information that I can see.

    Monday, March 23, 2015 6:10 PM
  • The easiest way would be to use automation (EnvDTE), getting the DTE service and then calling DTE.ActiveDocument.

    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Tuesday, March 24, 2015 6:29 AM
    Moderator
  • Easiest it is. Thanks.
    Tuesday, March 24, 2015 6:59 PM