Visual Studio's Context Menu

  • Thread starter Thread starter ron
  • Start date Start date
R

ron

Hi,

How can I add a menu options to the context menu in the
ide? I know how to add an option to the commandbar. I
am trying to write an add-in that is invoked by right-
click in the ide.

Thanks
 
I don't have the code, but my boss makes these for VS on a regular basis.
Send him an email at (e-mail address removed) His name is
Les Smith. I sent him an email too and will post if he gets back to me
first.

Bill
 
Thank you very much Yanhong, this was exactly what I was
looking for.

ron jc
-----Original Message-----
Hello Ron,

Thanks for posting in the group.

Here is how you could add a menu to the code editor context menu. The key
here was to get to the right command bar which is called "Code Window".
Please let me know if you have any questions.

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref system.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;

//Create the command and add it to the commands list
Command myMenuItemCmd;
Object []nullObj = {Type.Missing};

myMenuItemCmd = applicationObject.Commands.AddNamedCommand(addInInstance,
"MyMenuItem", "My Menu Item", "My memu item added to the code editor
context menu", false,10, ref nullObj, 1 + 2);
//Create a command bar menu item to be added to the context menu
Microsoft.Office.Core.CommandBarButton myMenuItem =
(Microsoft.Office.Core.CommandBarButton) (applicationObject.CommandBars["Code
Window"].Controls.Add.Microsoft.Office.Core.MsoControlTyp
e.msoControlButton,
1, Type.Missing, 1, Type.Missing ));
myMenuItem.Caption = "My Menu Item";

}

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "ron" <[email protected]>
!Sender: "ron" <[email protected]>
!Subject: Visual Studio's Context Menu
!Date: Fri, 29 Aug 2003 06:35:55 -0700
!Lines: 8
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!Thread-Index: AcNuMnlEtTti3zNPSJSPzI/UsCTkrw==
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Newsgroups: microsoft.public.dotnet.framework
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52546
!NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!Hi,
!
!How can I add a menu options to the context menu in the
!ide? I know how to add an option to the commandbar. I
!am trying to write an add-in that is invoked by right-
!click in the ide.
!
!Thanks
!

.
 
Back
Top