locked
Adding Addin Menu to Top RRS feed

  • Question

  • Hi,

    I have same addins and I want to put this addins to top standart menu (right side of Tools menu).

    I searched them how to do. I found Mz Tools article (http://www.mztools.com/articles/2005/MZ2005003.aspx) It is run when load first time. But problem is occured when opening visual studio (2010) second time. Addin menu on top stardart bar doesnt't appear. Other addin buttons appear (under tools menu, addin toolbar,..)

    How can I resolve my problem?

    Regards,

    Mehmet.

    Wednesday, January 4, 2012 8:07 AM

Answers

  • Hi Mehmet,

    This is because the 2nd time you run Visual Studio, the OnConnect method is not invoked with that same ext_cm_UISetup. Additionally, it appears you have modified Carlos sample code, such that you are trying to change the dropdown menu from temporary to permanent.

    As far as I'm aware, this is not possible. That is, I don't believe the CommandBarTypeMenu objects get peristed into the permanent layout. If you need to integrate a dropdown menu in the main menu that is permanent, you should probably be implementing a package with the VS SDK.

    The other alternative is to force your add-in to load on startup.

    Sincerely,


    Ed Dore
    Monday, February 6, 2012 9:51 PM

All replies

  • You need to give more information, and preferably a repro.  If you just copied the code from the article (without understanding what it was doing) then I imagine you copied this line

     ' Add a new commandbar popup
             myTemporaryCommandBarPopup2 = DirectCast(menuCommandBar.Controls.Add( _
                MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, _
                position, True), CommandBarPopup)

    Note the name 'myTemporaryCommandBarPopup2' and the last parameter to Controls.Add (True).  If you look at the MSDN documentation, you'll notice the name of the last parameter is 'Temporary' and the description is

    true if the bar is temporary, otherwise false.

    Temporary here means it won't be persisted between sessions.

    Ryan

    Wednesday, January 4, 2012 11:12 PM
  • Hi,

    This is code :

    // ------------------------------------------------------------------------------------
             // New main menu
             // ------------------------------------------------------------------------------------
    
             // Calculate the position of a new command bar popup to the right of the "Tools" menu
             toolsCommandBarControl = (CommandBarControl)toolsCommandBar.Parent;
             position = toolsCommandBarControl.Index + 1;
    
             // Try to delete the commandbar if it exists from a previous execution, 
             // because the /resetaddin command-line switch of VS 2005 (or higher) add-in 
             // projects only resets commands and buttons, not commandbars
             try
             {
                commandBars[MY_PERMANENT_COMMANDBAR_POPUP2_NAME].Delete();
                menuCommandBar.Controls[MY_PERMANENT_COMMANDBAR_POPUP2_CAPTION].Delete(false);
             }
             catch
             {
             }
    
             // Add a new commandbar popup 
             myPermanentCommandBar2 = (CommandBar)applicationObject.Commands.AddCommandBar(
                MY_PERMANENT_COMMANDBAR_POPUP2_NAME, vsCommandBarType.vsCommandBarTypeMenu, 
                menuCommandBar, position);
    
             // Get the actual commandbar popup
             myPermanentCommandBarPopup2 = (CommandBarPopup)myPermanentCommandBar2.Parent;
    
             // Change some commandbar popup properties
             myPermanentCommandBarPopup2.Caption = MY_PERMANENT_COMMANDBAR_POPUP2_CAPTION;
    
             // Add a new button on that commandbar popup
             myCommandBarPopup2Button = (CommandBarButton)myCommand.AddControl(myPermanentCommandBar2, 
                myPermanentCommandBar2.Controls.Count + 1);
    
             // Change some button properties
             myCommandBarPopup2Button.Caption = MY_COMMAND_CAPTION;
    


    it is not temprory, permanent.

    Mehmet

    Thursday, January 5, 2012 8:15 AM
  • Hello Mehmet,

    I am the author of the article "HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in" with the 4 samples (2 for VB.NET/C#, 2 for temporary/permanent approaches).

    You are using the C#/permanent case. Have you copied the whole code of the Connect class in a new C# add-in project? Or have you copied just some portions of the sample in your own existing add-in project?


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    Thursday, January 5, 2012 12:20 PM
  • Hello Carlos,

    I copied whoe code of Connect Class in a new c# (4.0) add-in project. When open visual studio fist time, no problem. Later I close visual studio (2010). When open the visual studio again, top add-in menu disappear. Other buttons (under the tools menu and other...) appear but top menu not.

    Thanks,

    Mehmet.

    Thursday, January 5, 2012 1:07 PM
  • Try this:

    - Close all VS 2010 instances

    - Using regedit.exe, go to the registry key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\PreloadAddinStateManaged and for your add-in change the value 2 to 1

    - Open VS 2010. The add-in should be loaded with all commandbars and buttons.

    - With regedit.exe, verify that the value is again 2

    - Close VS 2010

    - Open VS 2010. The add-in should be loaded with all commandbars and buttons.

    For an explanation, permanent UI for add-ins is tricky. See my articles and posts:

    devenv.exe /resetaddin doesn't fully reset the add-in
    http://msmvps.com/blogs/carlosq/archive/2009/06/23/devenv-exe-resetaddin-doesn-t-fully-reset-the-add-in.aspx

    INFO: Visual Studio .NET Add-In Commands Disappear On Next Session
    http://www.mztools.com/articles/2005/MZ2005014.aspx

    HOWTO: Reset a Visual Studio add-in
    http://www.mztools.com/articles/2006/MZ2006014.aspx



    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    Saturday, January 7, 2012 11:37 PM
  • Hi Carlos,

    All commandbars and buttons are appear without top menubar.

    it is disappear...

    Mehmet.

     

     

    Monday, January 9, 2012 9:06 AM
  • Hello,

    I have tried the sample in VS 2010 and it works for me, the top menu bar is created. I have found another issue where the UI is duplicated each time that you load VS 2010 because the ext_ConnectMode.ext_cm_UISetup phase is triggered every time when it shouldn't (it doesn't happen in VS 2008) but that's another issue that I will isolate, report and document when I have some spare time.

    Regarding your problem, it is difficult to know. You can either debug the code or puttting MesssageBoxes as traces in the code if you are not debugging it. If you don't find the problem you can always switch to the temporary user interface approach, which is less tricky.


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    Tuesday, January 10, 2012 4:57 AM
  • Hello,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 16, 2012 1:52 AM
  • Hello,

    My problem hasn't resolved yet. I am trying to resolve.

    Mehmet.

    Monday, January 16, 2012 9:48 AM
  • Hi MehmetK,

    Thank you for your updating.

    If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 23, 2012 5:20 AM
  • Hi Li,

    I have a few addin for my company. I am trying to put in top menu for example "ABC" as right side of Tools menu and left side of architecture menu.

    I want to put in "ABC" top menu my addins.  these example (mztools) only appear first time. Later disappeared.

    Regards,

    Mehmet.

    Tuesday, January 31, 2012 9:41 AM
  • Hi Mehmet,

    Based on the comment of Carlos, the way he introduced should work for this cases.

    Could you prepare a very simple sample project for us to test? It is not necessary that you send out the whole of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business details from it. You can use Microsoft Skydrive to upload the project and offer a link for us to download.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, February 1, 2012 5:08 AM
  • Hi Yi,

    I put the example project to Skydrive

    https://skydrive.live.com/redir.aspx?cid=7225eebc327442b9&resid=7225EEBC327442B9!162&parid=7225EEBC327442B9!123

    this project mztools example, fist time menu appear. After first time, disappear.

    Thaks,

    Mehmet.

     

    Wednesday, February 1, 2012 8:38 AM
  • Hi Mehmet,

    Thank for your sample, I will get back to you asap.

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, February 1, 2012 9:03 AM
  • Hi Mehmet,

    I can repro this on my side some time.

     

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

     

    Thank you for your understanding and support.

     

    Yi

     


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Yi Feng Li Monday, February 6, 2012 6:42 AM
    Monday, February 6, 2012 6:40 AM
  • Hi Mehmet,

    This is because the 2nd time you run Visual Studio, the OnConnect method is not invoked with that same ext_cm_UISetup. Additionally, it appears you have modified Carlos sample code, such that you are trying to change the dropdown menu from temporary to permanent.

    As far as I'm aware, this is not possible. That is, I don't believe the CommandBarTypeMenu objects get peristed into the permanent layout. If you need to integrate a dropdown menu in the main menu that is permanent, you should probably be implementing a package with the VS SDK.

    The other alternative is to force your add-in to load on startup.

    Sincerely,


    Ed Dore
    Monday, February 6, 2012 9:51 PM