2

I want to add a menu item to the context menu of all the files and folders in the solution explorer. I was able to add my menu item to the project node with this entry in the vsct file..

<Menu guid="guidERAPackageAlphaCmdSet" id="ERAInsightMenu" priority="0x0700" type="Context">
    <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD" />
    <Strings>
      <ButtonText>ERA Insight</ButtonText>
      <CommandName>ERA Insight</CommandName>
    </Strings>  
  </Menu>

I want to get this in the context menu of all files and folders in solution explorer. What is the id i should use? Is there any place where i can find the ids for all the menus in visual studio?

niruj
  • 125
  • 2
  • 9

2 Answers2

3

I know this is old, but hopefully this helps someone.

If you look at the top of your vsct file, you should see this:

  <!--This header contains the command ids for the menus provided by the shell. -->
  <Extern href="vsshlids.h"/>

The path will differ based on version, but you should be able to find it in a similar path to:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Common\Inc

This file contains a list of all of the constants and some have descriptions.

Here is an example of what could be used for the original question from the file:

// Common Item Node context menu
#define IDM_VS_CTXT_ITEMNODE          0x0430

// Folder Node context menu
#define IDM_VS_CTXT_FOLDERNODE        0x0431
Daniel
  • 502
  • 2
  • 9
  • 18
  • I find that IDM_VS_CTXT_ITEMNODE works for me for files in the project but IDM_VS_CTXT_FOLDERNODE does not seem to be working for me for folders (my query status callback is not called at all). There might be a catch to when the IDM_VS_CTXT_FOLDERNODE context menu is used ... – webjprgm Sep 29 '17 at 21:41
  • I've found [undocumented](https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/ide-defined-commands-for-extending-project-systems?view=vs-2019) `IDM_VS_CTXT_SOLNNODE` to adjust the solution node context menu. Thank you very much – oleksa Jul 07 '20 at 16:46
1

You can find the ID's of all the root menus (meaning it doesn't show the children of the context menus) using the trick described in this post:

http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

to summarize, you need to add a registry key at the following location: HKEY_CURRENT_USER/Software/Microsoft/VisualStudio/<your vs version>/General and the key to ass is of DWORD type named EnableVSIPLogging (you have to set it to 1)

then before right clicking to show the context menu, hold CTRL and SHIFT and you'll see a message box containing all the ID's you need

ppetrov
  • 3,077
  • 2
  • 15
  • 27