locked
How to remove 'data tip' related menu items from Debug menu? RRS feed

  • Question

  • Hi,

    I'm using the VS 2010 isolated shell.  I'm trying to remove the various data tip related menu items (Clear All DataTips, Export DataTips..., Import DataTips...) from the Debug menu.

    I see no option in the .vsct file to do so.  Is there a line(s) in .vsct  file or is there something else that needs to be done?

    Thanks,

    Notre

    Thursday, January 13, 2011 10:10 PM

Answers

  • Hi Ryan,

    That's disappointing about not being able to remove some command/command groups via the .vsct file.  Is there a place where I could request this functionality in a future version of VS?  I went to the MS connect site and found only a category for VS and .NET Framework, with nothing specific to VS extensibility.  I could make the enhancement request in the VS and .NET Framework area, but I'm afraid it will get lost in the big list.


     

    Note, I haven't checked on your specific commands, but if they don't appear to allow disabling them via VSCT level directives it is likely a bug/oversight.  We have 4k+ commands in VS and no central team owns them all, so it is highly likely there have been oversights in 'enabling' the ability to easily remove commands via VSCT.

    As for bugs, Connect is a good place, all VS bugs get routed internally so it will make its way to our team.  Alternatively, a faster method, but one with no public visibility for you to 'check on' would be to list all the commands here in a single message (or mail me rmolden AT microsoft DOT com) and I can open a bug internally about enabling them to be easily removed.

    If they aren't enabled for removal via VSCT then the only option would be a runtime hiding/disabling, or a customized profile for your app which just had those items deleted.  The customize profile route may be easier, but beware that ONLY removes the items from UI visibility, they would still 'be' there in the sense that any mechanism that would execute the commands NOT through the UI (i.e. DTE/general extensibility or keybindings) would still cause them to execute.

    A dedicated package would make it easiest to remove in the future when the commands WERE possible to remove via VSCT modifications.  It could also be set to auto-load on startup and would me more lightweight than autoloading other packages, many teams have small 'stub' packages that load only to handle dynamic command status updates and are much smaller/lighter weight than their full package.  If you set up only handlers for items you want to hide then you shouldn't have to worry about any sort of forwarding.  One wrinkle with menus is that if the menu itself hasn't been marked with DynamicVisibility (lots of them aren't) then its visibility is determined by it having at least one visible child, so if you want to hide a menu you would need to respond to every child it has saying they are all hidden.

    Ryan

    Friday, January 14, 2011 7:46 PM

All replies

  • Not all commands are individually removable, sometimes even whole groups are not authored to allow removal as the isolated shell stuff came along LONG after most of these commands were originally added/authored and it could be the case that the necessary VSCT updates were not made to allow easy removal of them.  You can register a priority command target (IVsRegisterPriorityCommandTarget) which at runtime says any command you want to be hidden is not visible/enabled.

    Ryan

    Friday, January 14, 2011 4:14 PM
  • Hi Ryan,

    That's disappointing about not being able to remove some command/command groups via the .vsct file.  Is there a place where I could request this functionality in a future version of VS?  I went to the MS connect site and found only a category for VS and .NET Framework, with nothing specific to VS extensibility.  I could make the enhancement request in the VS and .NET Framework area, but I'm afraid it will get lost in the big list.

    Back to priorty command targets :)  Are there any other options, or is that pretty much it?  I remember you started to help me with a solution based on priority command targets in a separate forum thread.  I ask about other options, because if priority command targets is the way to go, I have a couple of further questions.

    1. I have multiple packages in my isolated shell.  I wouldn't want to make each of their editors/toolwindow be priority command targets, and worry about conflicts between different, overlapping command routings.  Should I create a new, dedicated package that loads on startup whose sole job it is would be to act as a priority command target for just those commands I want to make invisible/disable for all packages, but that I can't do through the .vsct file?

    2. In the other forum thread, you outlined an algorithm to conditionally pass along commands from the priority command target.  Would I need to worry about this?   I'm thinking I would only setup handlers (I'm using IMenuCommandService) for just those commands I want to remove for all packages, so I wouldn't need to worry about any forwarding. (This assumes the dedicated package for handling unwanted commands).

    Thanks,

    Notre

    Friday, January 14, 2011 7:32 PM
  • Hi Ryan,

    That's disappointing about not being able to remove some command/command groups via the .vsct file.  Is there a place where I could request this functionality in a future version of VS?  I went to the MS connect site and found only a category for VS and .NET Framework, with nothing specific to VS extensibility.  I could make the enhancement request in the VS and .NET Framework area, but I'm afraid it will get lost in the big list.


     

    Note, I haven't checked on your specific commands, but if they don't appear to allow disabling them via VSCT level directives it is likely a bug/oversight.  We have 4k+ commands in VS and no central team owns them all, so it is highly likely there have been oversights in 'enabling' the ability to easily remove commands via VSCT.

    As for bugs, Connect is a good place, all VS bugs get routed internally so it will make its way to our team.  Alternatively, a faster method, but one with no public visibility for you to 'check on' would be to list all the commands here in a single message (or mail me rmolden AT microsoft DOT com) and I can open a bug internally about enabling them to be easily removed.

    If they aren't enabled for removal via VSCT then the only option would be a runtime hiding/disabling, or a customized profile for your app which just had those items deleted.  The customize profile route may be easier, but beware that ONLY removes the items from UI visibility, they would still 'be' there in the sense that any mechanism that would execute the commands NOT through the UI (i.e. DTE/general extensibility or keybindings) would still cause them to execute.

    A dedicated package would make it easiest to remove in the future when the commands WERE possible to remove via VSCT modifications.  It could also be set to auto-load on startup and would me more lightweight than autoloading other packages, many teams have small 'stub' packages that load only to handle dynamic command status updates and are much smaller/lighter weight than their full package.  If you set up only handlers for items you want to hide then you shouldn't have to worry about any sort of forwarding.  One wrinkle with menus is that if the menu itself hasn't been marked with DynamicVisibility (lots of them aren't) then its visibility is determined by it having at least one visible child, so if you want to hide a menu you would need to respond to every child it has saying they are all hidden.

    Ryan

    Friday, January 14, 2011 7:46 PM
  • Hi Ryan,

    Thanks for the detailed reply and explanation!

    As far as probable bugs in the inability to remove certain commands via the .vsct file, I'll create a new forum question that lists all the areas  I think are missing (at least those I've come across), and then email you a link to that forum question.  I've got several other forum questions open right now (which you may have noticed) about how to remove items via the .vsct.  I'll give those questions a few days to see if any further responses come, and if not, I'll compile the list.

    Notre

    Friday, January 14, 2011 9:50 PM
  • Using the dedicated package described by Ryan above works.  You also need the command guids/ids, which are not in the SDK header files/constants.  See these two threads:

    http://social.msdn.microsoft.com/Forums/en/vsx/thread/a1575efb-1d47-49ac-8f40-e1a48521b063

    http://social.msdn.microsoft.com/Forums/en/vsx/thread/479697e6-d92f-4679-84b2-18a5f228e211

    Notre

    Tuesday, January 18, 2011 5:44 PM
  • Hi Notre & Ryan,

    I was facing this probem in my application.  For reference, you can see my problem -

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/8d899038-173f-44b8-96f9-92d03a1eabb2/how-to-remove-export-data-tips-clear-all-data-tipsimport-data-tips-options-settings-sub?forum=vsx

    I tried few solutions but in vain .. !! So I got solution using DTE.

                    

     public void HandleVisibility()
            {
                DTE dte = GetService(typeof(SDTE)) as DTE;
                if (dte != null)
                {
                    CommandBars commandBars = dte.CommandBars as CommandBars;
                    CommandBar menuBarCommandBar = commandBars["MenuBar"];

                    CommandBarControls menuBarControls = menuBarCommandBar.Controls;
                    foreach (CommandBarControl commandBarControl in menuBarControls)
                    {
                        if (commandBarControl.Type == MsoControlType.msoControlPopup)
                        {
                            CommandBarPopup commandBarPopup = commandBarControl as CommandBarPopup;
                            if (commandBarPopup.CommandBar.Name == "Debug")
                            {
                                foreach (CommandBarControl child in commandBarPopup.CommandBar.Controls)
                                {
                                    try
                                    {
                                        switch (child.Caption)
                                        {
                                            case "Clear &All DataTips":
                                            case "E&xport DataTips ...":
                                            case "Im&port DataTips ...":
                                             case "Options and Settin&gs...":
                                                {

    // Set Enable property to true because, state of these commands can be disable and if delete these commands, it throws an exception. So set enable to true.

                                                    commandBarPopup.CommandBar.Controls[child.Caption].Enabled = true;
                                                    commandBarPopup.CommandBar.Controls[child.Caption].Delete();
                                                }
                                                break;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }
                                }
                            }
                        }
                    }
                }
            }

    Please let me know if you have any problem.

    Thanks,

    Sudarshan

    Monday, February 17, 2014 10:28 AM