Add item to Visual Studio source control context menu - visual-studio

I would like to create an extension for VS Source Control Explorer context menu,
In order to add an option on the Text Editor context menu I know you need to set IDM_VS_CTXT_CODEWIN on Group's Parent node into the vsct file.
Can someone tell me the correct value for Source Control Explorer context menu?

I don't think that particular context menu guid:id pair is published anywhere. I usually try searching the various .VSCT files under the ….VSSDK\VisualStudioIntegration\Common\Inc directory to find a unique menu item in the context menu, figure out what menu group it's parented to, and work back from there.
But given the thousands of commands and menus wired into the IDE, this can be a hit or miss scenario.
When a search of the various .VSCT files on the above mentioned path doesn't pan out, I usually revert to using the EnableVSIPLogging registry key, to discover the guid:id pair for the given context menu.
Easiest way to set this is to install Mad's Extensibility Tools extension, which adds an "Enable VSIP Logging" command on the IDE's main "View" menu. Once you set this, if you hold down the CTRL+SHIFT keys, while right clicking in the Toolwindow, you'll get a diagnostic message box, with the guid and id of the context menu. You can use these as the parent for the menu group containing your command.
For example:
VSDebug Message
Menu data:
Guid = {**FFE1131C-8EA1-4D05-9728-34AD4611BDA9**}
GuidID = 962
CmdID = ***4113***
Type = 0x00000400
Flags = 0x04000000
NameLoc = (null)
OK
Where FFE1131C-8EA1-4D05-9728-34AD4611BDA9 is the context menu guid, and 4113 is the menu id.
Note, if you hold the CTRL+SHIFT while selecting an actual command, the same dialog will appear, but the guid and cmdid, will identify the specific command(menu item) selected.
Sincerely,

Related

Find all references in VS 2013 Pro not an option anymore

I used to be able to right click and select find all references for a method or something and then that box would open and show me all of the places in my code where it was being used. All of the sudden if I right click I no longer get that option.
This is still in all recent versions of Visual Studio. Cntl+K, R is the keyboard shortcut. If it's not appearing in your context menu, it is something specific to your VS configuration/settings.
You can edit your context menu's by the following:
Goto Tools->Customize
Select the Commands tab
Select the Context menu radio button
Select the appropriate context menu from the dropdown list to the right: (Editor Context Menus | Code Window or Other Context Menus | Code Window)
Add or delete context menu items as desired.
When adding a context menu command, the Find All References command is located under the Edit section.

how to add new items to certain file extension context menu

how to add new items to certain file extension context menu (to .mp3 files for instance)
I've also noticed that there is common items in all context menus across the windows, does they all share/inherit one context menu ? where is it : which one is for text
what such keys are called and how to generate them (for instance {11dbb47c-a525-400b-9e80-a54615a090c0})
also is there a good brief reference for the registry that you would recommend ?
Type regedit in RUN dialog box or Start Menu searchbox and press Enter. It'll open Registry Editor, now go to following keys:
HKEY_CLASSES_ROOT* (for adding an option in All files context menu)
HKEY_CLASSES_ROOT\Directory (for adding an option in folders context menu only)
HKEY_CLASSES_ROOT\Drive (for adding an option in Drives context menu only)
HKEY_CLASSES_ROOT\Unknown (for adding an option in unknown files context menu)
Now under the above mentioned keys, you'll find "Shell" and "Shellex" keys. Both keys contain various entries, which are displayed when you right-click on a file, folder or drive. We'll use "Shell" key in this example:
Right-click on the "Shell" key and select "New -> Key".
Give it any name. Suppose we gave it name "Demo".
Now in right-side pane, double-click on "Default" String value and set its value to the Label which you want to display in context menu. Like if you want to add "Winamp" in context menu, then you can give it name "Open with Winamp" or similar.
Now create another key under this newly created key "Demo" with the name "command" and in right-side pane set value of "Default" to the path of application. For ex, for winamp you can set its value %programfiles%\Winamp\winamp.exe.
A full reference to this can be found here
how to add new items to certain file extension context menu
How you massage the registry to create context menu item entries is already covered by this MSDN article. It is extensive and well done, no need to repeat it here.
I've also noticed that there is common items in all context menus across the windows
The majority of them are baked-in items that Explorer itself understands. There is a backdoor to add an item yourself to any file, the HKCR\* registry key is used. Use this sparingly, it is pretty annoying to users.
for instance {11dbb47c-a525-400b-9e80-a54615a090c0}
That's an example of a custom shell extension handler, you found this one back in the HKCR\Folder registry key, the key that adds items to any directory. Think of it as a plug-in that adds capabilities to Explorer that it doesn't have itself. The {guid} selects the executable file that Explorer loads to implement the item. Navigate to HKCR\Classes\CLSID\{guid} to see that file, you'll see it is implemented by c:\windows\system32\explorerframe.dll
Writing your own shell extension handler is not that easy, it requires COM coding skills in C++. A coding technique that is getting obscure. Using something like C# is technically possible but strongly discouraged by Microsoft and they won't support it. You need to write an in-process COM server that implements the IContextMenu interface. Programming guide is here.

How do I modify the "Add" sub menu items in solution explorer?

How can I modify the items that appear in the solution explorer "Add" context sub menu? Currently there is New Item, Existing Item, New Folder, then Windows Form, User Control, then Component and Class. I especially want to get rid of the 2 WinForms items and replace them with their WPF counterparts. How do I do that in the easiest way?
You can modify the Add sub menu you get when you right click on a project item from the Tools->Customize... menu:
click on the Commands tab
pick the 'Context Menu' radio button
select Project and Solution Context Menus | Project | Add from the combo box
From here you can modify the context menu.
This is not, however, what you want to do in your particular case.
The WPF commands you want are already in that context menu; you'll see WPF commands like "Add Window" and "Add Page" already present in the Customize dialog if you go through the instructions above. The reason that you don't see them in the actual context menu is because Visual Studio is trying to be smart and it thinks that you're developing a WinForms app and not a WPF app. If it thought this was a WPF app, you wouldn't see the windows forms option (and the user control option would create a WPF user control).
In order to correct visual studio's incorrect assumption, you could make a new project - make sure you pick that you want a WPF app - and add all of your existing files, or you can edit your .csproj file: see my answer to this SO question.

VS2010, VSpackage, adding command for certain filetypes in the context menu?

I'm developing a vspackage for executing *.bat files in my vs2010 solutions.
Therefore I need a button when I right click my files to get a context-menu in solution explorer.
I would like the button only to be visible when right clicking *.bat files. Is that possible?
You can achieve this quite easily. First, you need to create menu item in solution explorer context menu. You can learn how to add menu items in general on MSDN.
To be more exact, you need set your menu group's parent to:
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
Both guid and id are predefined in Visual studio, the latter means that the menu item will be displayed whenever user clicks on standard project item. However, you need it only to appear when the name of the file ends with ".bat". This can be achived in BeforeQueryStatus method - see MSDN link above. To find out selected nodes in solution explorer, use
(UIHierarchy)ideObject.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Object
which has SelectedItems property.

Hide items in the right-click context menus in Visual Studio 2010 (08)?

The right-click context menus of the source editor, the project items and the solution item, is getting ridiculously long, and two of them even have scrolling now on my 1680x1050 screen.
Is there any way for me to hide items on these menus, even if I have to add an event to my Visual Studio macro-system and find and hide them manually?
Here's examples, many of these items I never use:
Edit1: The current answer + comments suggest I should use the Customize menu item in the toolbar context menus, go to the second tab, Commands, and use the Context Menus radio selection and find the relevant menus there.
Here are 3, which are suggested by comments:
As you can see, they're all empty.
Edit2: After clicking the "Reset All" button in that dialog, for the Solution and Project menus, I got items in the dialog, that I could edit, but the changes did not affect the actual context menu on either a project or the solution file. Also, after restarting Visual Studio, the dialog contents for those two were again empty.
In Visual Studio 2010 you can:
Goto Tools->Customize
Select the Commands tab
Select the Context menu radio button
Select the appropriate context menu from the dropdown list to the right, and delete away
I believe Visual Studio 2008 is similar.
You will need to choose the correct context menu in the Customise option.
Go to Tool > Customise,
Then choose the Context menu as you did in your Edit1 screenshots but choose "Editor Context Menus | Code Window" from the dropdown menu instead.
From there you should be able to delete whatever command you don't need from your context menu. Next, for the other commands that can't be found in Editor Context Menus | Code Window (mostly plug-ins or extensions related commands) you will have to go through other categories.
For example, I am using CodeMaid and when I right click a file in Solution Explorer the context menu below are shown
In order to remove the 'Cleanup Selected Code' command I will have to choose the Project and Solution Context Menus | Solution Folder dropdown option.
Added: Here is my sample reduced context menu (removed Copy, Cut, Paste, Outline Menu and Create Snippet...)
Hope this helps =)
Edit: In case you want to add back the commands you removed you can either add them back using New Command... or just press Reset All. Keep in mind the later will restore all the commands. Thus unless you are really having trouble finding the removed command use the first method.
I use 3 VS extensions and these 3 are responsible for polluting the context menu:
VSCommands
Power Commands
Power Toys
Using their own options dialogue, it's possible to subject showing those menus to pressing CTRL (in VS Commands) or completely disable them (the other 2 extensions)

Resources