Add context meu item to all files and folders in the solution explorer using vspackage

你。 提交于 2020-01-03 04:34:15

问题


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?


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/13467477/add-context-meu-item-to-all-files-and-folders-in-the-solution-explorer-using-vsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!