How do I add an entry to the Menu in the Solution Explorer??

How do I add an entry to the "Integration Srevices Project" Menu in the Solution Explorer
 
When working with Sql Server 2005, I opened a new "Integration Services" project of type "Business Intelligence" project.
When I right click on the project name in the Solution Explorer, I get a menu with (Build, ReBuild, Clean... ).
 
How can I add a new entry to this menu I created a wizard as described in http://msdn2.microsoft.com/en-us/library/7k3w6w59(VS.80).aspx but I can't find where to locate the vsz file.
 
Note: In the document above, it's mentioned that in order to run the wizard, I need to go through "Add->New Item"... Is there a way to actually add a new entry to the menu
 
Thanks,
Sami.


Answer this question

How do I add an entry to the Menu in the Solution Explorer??

  • DocJames

    Hi,

    To add a menu entry to a context menu is the same that adding it to any VS menu or toolbar. All of them work with command bars (of 3 kinds: menu, toolbar, commandbar popup). So, you don’t use a handle at all. All you need to know is the name of the commandbar popup that a window is using as context menu. The Solution Explorer uses quite a few depending on the selected item(s) such as "Project", etc. To guess the name of the commandbar used by the Object Browser as context menu (if it is not internal to it, I am not sure) see if this helps:

    HOWTO: Guessing the name of a command bar to add a custom menu entry in Visual Studio .NET add-ins

    http://www.mztools.com/articles/2004/MZ002.htm



  • Atosecond

    Hi Sami,
    Thanks for that but it doesn't seem to work for my implementation, which line of code in particulat is adding the command to the Solution Explorer



  • Armageddon

    Hi Sami,
    I'm trying to do much the same thing but haven't succeeded, did the "Project" add a new menu item to the Solution Explorer for you, it didn't for me , just added it to the Menu Project and not the right click menu.
    Here's what I'm using:

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    if(connectMode == ext_ConnectMode.ext_cm_UISetup)
    {
    object []contextGUIDS = new object[] { };
    Commands2 commands = (Commands2)_applicationObject.Commands;
    string projectMenuName;


    try
    {
    ResourceManager resourceManager = new ResourceManager("MyAddin.CommandBar", Assembly.GetExecutingAssembly());
    CultureInfo cultureInfo = new System.Globalization.CultureInfo(_applicationObject.LocaleID);
    string resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Project");
    projectMenuName = resourceManager.GetString(resourceName);
    }
    catch
    {
    //We tried to find a localized version of the word Tools, but one was not found.
    // Default to the en-US word, which may work for the current culture.
    projectMenuName = "Project";
    }

    try
    {
    Command solutionExplorerCommand = commands.AddNamedCommand2(_addInInstance, "MyContextMenu", "My Command", "Executes My command 1", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,(int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
    Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar2 = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];
    CommandBarControl projectControl = menuBarCommandBar2.Controls[projectMenuName];
    CommandBarPopup projectPopup = (CommandBarPopup)projectControl;

    if ((solutionExplorerCommand != null) && (projectPopup != null))
    {
    solutionExplorerCommand.AddControl(projectPopup.CommandBar, 1);
    }

    }
    catch
    {
    }

    }
    }


  • Bill S

    Sami, I'm trying the same thing as you, adding a context menu to the solution explorer.


  • Devi48354

    Craig Skibo wrote:

    Creating a menu item and a wizard are two seperate concepts. Creating a menu item involves walking through the object model for command bars, locating the correct CommandBar object, and adding an item to it.

    Craig

    Thanks for your answer Craig.
    My problem now is that I have no idea what the name of correct command bar that I need!!
    I am creating an "Integration Service Project" by going through File->New->Project->"Business Intelligence Projects" and choosing "Integration Service Project".
    When I open the "Solution Explorer" of the new project and I right click on the project, I want to be able to add an entry to the menu that I get there. Does anyone know what is the name of that menu What name should I use in order to locate it so I can add a command to it
    I am trying to use the same technique as described in http://msdn2.microsoft.com/en-us/library/ms165628(VS.80).aspx
    Thanks,
    Sami.

  • Jeries Shahin

    It works now of course, but how I don't see how it gets a handle to the Solution Explorer:

    Command solutionExplorerCommand = _applicationObject.Commands.AddNamedCommand(_addInInstance, "IDESolutionExplorerContextMenu", "IDE Solution Explorer Context Menu", "Executes IDE Solution Explorer Context Menu", true, 100, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);
    Microsoft.VisualStudio.CommandBars.CommandBar projectCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["Project"];
    Microsoft.VisualStudio.CommandBars.CommandBarControl projectCommandBarControl = (Microsoft.VisualStudio.CommandBars.CommandBarControl)solutionExplorerCommand.AddControl(projectCommandBar, projectCommandBar.Controls.Count);
    projectCommandBarControl.Caption = "IDE Solution Explorer Context Menu Caption";

    BTW I have decided to add the context menu to the Object Browser, any idea how to get a handle to this window

    Thanks.


  • alipunk

    Creating a menu item and a wizard are two seperate concepts. Creating a menu item involves walking through the object model for command bars, locating the correct CommandBar object, and adding an item to it.

    Creating a wizard involves creating a .vsz file and putting that vsz file into the correct location on disk so that it can be found by either the New Project or Add New Item dialog boxes. I am not familiar with the SQL tools, but running a wizard involves finding the directory on disk to put the vsz file, not modifying the menu. It is possible that the SQL tools do not allow you to show the Add New Item dialog box, in that case you will need to find a new method to show the .vsz file - like adding a menu item to show a custom dialog to allow you to start the wizard running.

    Craig



  • Parag Kudtarkar

    Never mind... I figured it out.
    It's called simply "Project".

  • B o g d a n

    learnerplates wrote:
    Hi Sami,
    Thanks for that but it doesn't seem to work for my implementation, which line of code in particulat is adding the command to the Solution Explorer

    I think we are talking about different things here. My question (and the solution that I posted) talked about adding an entry to the contect menu in the solution explorer (right click on the project in the solution explorer) while I guess that you are intersted in adding an entry to the solution explorer it self. Am I right

  • AravananRaman

    I did it a little bit different:
    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
    Command cmd1;
    Microsoft.VisualStudio.CommandBars.CommandBar cmdBar;
    CommandBarControl cmdBarCtl1;
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    if (connectMode == ext_ConnectMode.ext_cm_UISetup)
    {
    try
    {
    object[] contextGUIDS = new object[] { };
    cmd1 = _applicationObject.Commands.AddNamedCommand(_addInInstance, "myAddin", "myAddin", "Executes the command for myAddin", true, 0/*59*/, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);
    cmdBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["Project"];
    cmdBarCtl1 = (Microsoft.VisualStudio.CommandBars.CommandBarControl)cmd1.AddControl(cmdBar, cmdBar.Controls.Count);
    cmdBarCtl1.Caption = "My new command";
    }
    catch
    {
    System.Windows.Forms.MessageBox.Show("Command could not be added to the menu context!");
    }
    }
    }
    I hope this helps.
    Sami.

  • How do I add an entry to the Menu in the Solution Explorer??