1

In a VSIX project, in the .vsct file I can see how to target different objects and provide a custom context menu:

For instance, the following will target an item node in the solution explorer:

 <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/> <!--<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>--> </Group> 

Changing the id property from IDM_VS_CTXT_ITEMNODE to IDM_VS_CTXT_CODEWIN will result in the context menu appearing in the code window instead.

This is documented here: Microsoft Documentation

However, I would like my context menu to appear in the 'Server Explorer' instead. An example and a link to the documentation would be very helpful.

3 Answers 3

4

To find Visual Studio menu guids, this usually works. In your registry set EnableVSIPLogging DWORD to 1, under HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\General.

Restart Visual Studio (and computer?) and hold Ctrl+Shift and right click an item in the server explorer, it will open a dialog window with something like this:

enter image description here

You can go from there.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the response. Unfortunately, I can't find that key under 14.0/General or with a search. I'm using VS 2015 Professional.
You have to create it "EnableVSIPLogging" DWord = 1
2

Thanks to Paul Swetz and James Sinclair I was able to get this working.

Using the method described by Paul Swetz I could identify the guid required for the Server Window object I was clicking, in this case the table node.

Having got that I added that id to the Symbols in the .vsct file, with a name of my choice:

<GuidSymbol name="guidWhatever" value="{d4f02a6a-c5ae-4bf2-938d-f1625bdca0e2}"> <!--//server explorer - table--> <IDSymbol name="IDMX_DV_OBJECT_NODE" value="0x8200"/> </GuidSymbol> 

Now I can use that in Groups and the custom command appears in the dropdown.

<Groups> <Group guid="guidFirstCommandPackageCmdSet" id="MyMenuGroup" priority="0x0600"> <!--<Parent guid="{D309F791-903F-11D0-9EFC-00A0C911004F}" id="IDM_VS_CTXT_ITEMNODE"/>--> <Parent guid="guidWhatever" id="IDMX_DV_OBJECT_NODE"/> </Group> </Groups> 

The only problem now is identifying and accessing the selected table and database but that's another matter.

2 Comments

Did you ever figure out how to determine what the selected table and database were?
I didn't, I'm afriad.
1

All of VS 2015's commands, menus, toolbars etc are detailed in a couple of c++ header files (stdidcmd.h and vsshlids.h).

On my install they are in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Inc'.

Had a very brief look in the files and i think you'll need something starting

  • IDG_SE_CONTEXT_ to target groups within the server explorer context menu
  • IDG_SE_TOOLBAR_ to get into the toolbar
  • IDM_SE_CONTEXT_ to get to the context menu
  • IDM_SE_TOOLBAR_ to get to the toolbar menu

1 Comment

Thanks to the two answers I was able to get this working, but it required an extra step, outlined below.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.