0

Im trying to rewrite our addin for SSMS 2014 to an extension for SSMS 2016.

I can't seem to find a way to add a menu or command to the context menu of the object explorer.

On the Microsoft website I can find lots of id's for all the windows (https://msdn.microsoft.com/en-us/library/cc826118.aspx) but not for the object explorer (object browser is a different window)

For the solution explorer I can use the following in the vsct file:

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_SOLNNODE"/>

Can anyone tell me the id for the object explorer context menu?

jwpfox
  • 5,124
  • 11
  • 45
  • 42
Ylluks
  • 1
  • 2

1 Answers1

1

Something like this

private IObjectExplorerService explorerService;
private List<MenuItem> menuItems = new List<MenuItem>();
// init
explorerService = DteServices.GetService<IObjectExplorerService>(dte);
//
explorerService.GetSelectedNodes(out nodeCount, out nodes);
INodeInformation node = nodes[0];
IMenuHandler menuHandler = node.GetService(typeof(IMenuHandler)) as IMenuHandler;
MethodInfo addChildMethod = menuHandler.GetType().GetMethod("AddChild");

for (int i = 0; i < menuItems.Count; i++)
  addChildMethod.Invoke(menuHandler, new object[] { string.Empty, menuItems[i] });

DteServices - it's our internal class. Please check MSDN How to: Get a Service from the DTE Object

vik_78
  • 1,107
  • 2
  • 13
  • 20