locked
How to add context menu in the item . RRS feed

  • Question

  • Hi,

    I am integrating Visual Studio 2008 using VSIP. I have selected Distributed System from the project template and added some Application from tool box such as Windows Aplication and ASP.netWebService now I want to add a menu item to the context menu of each of item and get the node name/file path etc.
    The thing will be same as we can add context menu item in code window.

    Can any one help..

    Thanks,
    AKB

    Wednesday, February 24, 2010 9:27 AM

Answers

  • Hello, AKB

    With VS SDK Assist and VSCT PowerToy, we could get “Implement Application” menu item’s GUID and ID, and its parent ID. They are listed below.

    Implement Application menuItem: GUID, {17BB613-0D18-483D-B662-63FEB409FC4D}, command ID: 1056824

    Its parent Group: {2d1cf427-ba58-4e35-bed7-bbb8c9691c56} command ID: 0x101014.

    So we could define a Group with its parent GUID and command ID, make your own menu item a son of this Group.

    Here is a simple VSCT script that add a menu item “My CMD1” to the context menu.

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

     

      <!--This is the file that defines the IDs for all the commands exposed by VisualStudio. -->

      <Extern href="stdidcmd.h"/>

     

      <!--This header contains the command ids for the menus provided by the shell. -->

      <Extern href="vsshlids.h"/>

     

      <!--Definition of some VSCT specific constants. In this sample we use it for the IDs inside the guidOfficeIcon group. -->

      <Extern href="msobtnid.h"/>

     

     

      <Commands package="guidVSPackageVSCTPkg">

        <!--This is the defination of the parent Group-->

        <Groups>

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

          </Group>

        </Groups>

       

        <Buttons>

          <!--your own menu item you want to add-->

          <Button guid="guidVSPackageVSCTCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">

            <Parent guid="guidVSPackageVSCTCmdSet" id="MyMenuGroup" />

            <CommandFlag>TextChanges</CommandFlag>

            <Strings>

              <CommandName>cmdidMyCommand</CommandName>

              <ButtonText>My CMD1</ButtonText>

            </Strings>

          </Button>

        </Buttons>

      

        <!--The bitmaps section is used to define the bitmaps that are used for the commands.-->

        <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="guidVSPackageVSCTPkg" value="{cd89937c-ef3b-42b6-812e-b96287b9f682}" />

       

        <!-- This is the guid used to group the menu commands together -->

        <!--{2d1cf427-ba58-4e35-bed7-bbb8c9691c56} is the parent GUID, and 0x101014 is its Command ID-->

        <GuidSymbol name="guidVSPackageVSCTCmdSet" value="{2d1cf427-ba58-4e35-bed7-bbb8c9691c56}">

          <IDSymbol name="MyMenuGroup" value="0x101014" />

          <IDSymbol name="cmdidMyCommand" value="0x0100" />

        </GuidSymbol>

           

        <GuidSymbol name="guidImages" value="{ba0f7e85-6724-422a-ad9c-e4b0d4033694}" >

          <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>

    If you have anything unclear, feel free to let me know.

    Thanks

    Chao

    • Marked as answer by Chao Kuo Monday, March 1, 2010 5:49 AM
    Friday, February 26, 2010 8:36 AM

All replies

  • I recommend Resources about Visual Studio .NET extensibility , there are several articles regarding adding buttons, commands, etc.
    Wednesday, February 24, 2010 10:24 AM
  • I have gone through the link but it does not contain any solution related to what I need.
    Thursday, February 25, 2010 7:28 AM
  • Hello, AKB

    With VS SDK Assist and VSCT PowerToy, we could get “Implement Application” menu item’s GUID and ID, and its parent ID. They are listed below.

    Implement Application menuItem: GUID, {17BB613-0D18-483D-B662-63FEB409FC4D}, command ID: 1056824

    Its parent Group: {2d1cf427-ba58-4e35-bed7-bbb8c9691c56} command ID: 0x101014.

    So we could define a Group with its parent GUID and command ID, make your own menu item a son of this Group.

    Here is a simple VSCT script that add a menu item “My CMD1” to the context menu.

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

     

      <!--This is the file that defines the IDs for all the commands exposed by VisualStudio. -->

      <Extern href="stdidcmd.h"/>

     

      <!--This header contains the command ids for the menus provided by the shell. -->

      <Extern href="vsshlids.h"/>

     

      <!--Definition of some VSCT specific constants. In this sample we use it for the IDs inside the guidOfficeIcon group. -->

      <Extern href="msobtnid.h"/>

     

     

      <Commands package="guidVSPackageVSCTPkg">

        <!--This is the defination of the parent Group-->

        <Groups>

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

          </Group>

        </Groups>

       

        <Buttons>

          <!--your own menu item you want to add-->

          <Button guid="guidVSPackageVSCTCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">

            <Parent guid="guidVSPackageVSCTCmdSet" id="MyMenuGroup" />

            <CommandFlag>TextChanges</CommandFlag>

            <Strings>

              <CommandName>cmdidMyCommand</CommandName>

              <ButtonText>My CMD1</ButtonText>

            </Strings>

          </Button>

        </Buttons>

      

        <!--The bitmaps section is used to define the bitmaps that are used for the commands.-->

        <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="guidVSPackageVSCTPkg" value="{cd89937c-ef3b-42b6-812e-b96287b9f682}" />

       

        <!-- This is the guid used to group the menu commands together -->

        <!--{2d1cf427-ba58-4e35-bed7-bbb8c9691c56} is the parent GUID, and 0x101014 is its Command ID-->

        <GuidSymbol name="guidVSPackageVSCTCmdSet" value="{2d1cf427-ba58-4e35-bed7-bbb8c9691c56}">

          <IDSymbol name="MyMenuGroup" value="0x101014" />

          <IDSymbol name="cmdidMyCommand" value="0x0100" />

        </GuidSymbol>

           

        <GuidSymbol name="guidImages" value="{ba0f7e85-6724-422a-ad9c-e4b0d4033694}" >

          <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>

    If you have anything unclear, feel free to let me know.

    Thanks

    Chao

    • Marked as answer by Chao Kuo Monday, March 1, 2010 5:49 AM
    Friday, February 26, 2010 8:36 AM
  • Hello, AKB

    Because you have started another question in your thread, So please start another thread. And Let me know the New thread.

    Thanks

    Chao

    Monday, March 1, 2010 5:57 AM