Visual Studio Extension: How to disable native command?

眉间皱痕 提交于 2019-12-11 17:18:42

问题


I build an extension that manages correctly Git Modules and, to do so, I have a folder in the solution called SubModules.

I managed to add my context menu to the solution file and to the project files, but I would like to disable some native commands when right-clicking on my SubModules folder (i.e. Remove, Add).

Is there a way to disable such native command?

I tried exploring EnvDTE80.DTE2.Commands, but no luck and searching tells me how to disable my own commands (which I already know how).

My extension is developed in C#, but an answer in VB.Net is alright too.


回答1:


You can subscribe to commandEvents.BeforeExecute, check the command name in the handler and set CancelDefault = true to disable a command. See Add confirmation before running Build.RebuildSolution and other rebuild commands.



来源:https://stackoverflow.com/questions/54566625/visual-studio-extension-how-to-disable-native-command

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