locked
Removing/hiding project node context menu items RRS feed

  • Question

  • I have managed to remove some of the itemsform the project node context menu but there are some i wish to remove that i cannot seem to figure out how to do so. I have removed the add menu and its sub-items and i have removed the add reference, this was all done via querystatusonnode. How ever i wish also to remove the following,

    Project Dependancies
    Project Build Order
    Set as Startup
    Debug
    Unload Project
    Clean

    but using the same approach as i did for the other items doesnt work on these.

    Can any one tell me how i can remove these items?
    Monday, September 24, 2007 12:08 PM

Answers

  • Try changing QueryStatus.NOTSUPPORTED to QueryStatus.SUPPORTED. When you set the QueryStatus.NOTSUPPORTED flag, the command continues to be routed through the IOleCommandTarget chain, and eventually someone will return an NOTSUPPORTED value, but invariably fails to set the INVISIBLE flag.

     

    Setting QueryStatus.SUPPORTED ensures that the command processing stops here.

     

    Sincerely,

    Wednesday, September 26, 2007 6:50 PM

All replies

  • Can you provide some additional information concerning what your QueryStatusOnNode looks like? Have you been able to establish what the proper guid:id pair is for the other menu items? For example, using the EnableVSIPLogging switch to identify those particular commands/menu items.

     

    If the context menu doesn't really bear any resemblance to the default project context menu, you could just build your own instead, and override the hierarchy node's DsplayContextMenu implementation to swap in your own, in lieu of the default IDM_VS_CTXT_PROJNODE menu.

     

    Sincerely,

    Monday, September 24, 2007 5:49 PM
  • My QueryStatusOnNode looks like this:

    protected override int QueryStatusOnNode(Guid guidCmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
    {
       //Hides context menu items that are not needed in the custom package
                if (guidCmdGroup == Microsoft.VisualStudio.Package.VsMenus.guidStandardCommandSet97)
                {
                    switch ((VsCommands)cmd)
                    {
                        case VsCommands.ProjectDependencies:
    case VsCommands.SetStartupProject:
                        case VsCommands.BuildOrder:
                        case VsCommands.AddExistingItem:
                        case VsCommands.AddNewItem:
                        case VsCommands.NewFolder:
                            result |= QueryStatusResult.NOTSUPPORTED | QueryStatusResult.INVISIBLE;
                            return VSConstants.S_OK;
                    }

    An di have stepped through my code and seen that these cmd do get fired and they get set to invisible and notsupported but yet the items still appear on the context menu.

    The reason i want to use the original menu is so that any add ons that use the project node menu as a place for their commands will still be visible for my project type. However I may use the project item menu instead as most addins use this menu aswell as the project one, since there would be less to remove from it.

    Tuesday, September 25, 2007 9:09 AM
  • Try changing QueryStatus.NOTSUPPORTED to QueryStatus.SUPPORTED. When you set the QueryStatus.NOTSUPPORTED flag, the command continues to be routed through the IOleCommandTarget chain, and eventually someone will return an NOTSUPPORTED value, but invariably fails to set the INVISIBLE flag.

     

    Setting QueryStatus.SUPPORTED ensures that the command processing stops here.

     

    Sincerely,

    Wednesday, September 26, 2007 6:50 PM
  • Thanks.
    Thursday, September 27, 2007 8:24 AM