Gary Depue's VSTA Blog

VSTA Integration experiences and discussion

Using the DTE to customize VSTA IDE menus

 

Using the DTE, you can customize the UI and user interaction of the VSTA IDE. 

 

Here's a quick snippet that shows how to add a ‘La&unch Something’ menu button to the Tools menu of the VSTA IDE. 

 

CustomizeIDEMenu() is a method in the host application that assumes that VSTA is initialized and a valid reference to the DTE is provided.

 

        public void CustomizeIDEMenu()

        {

            Object objMissing = System.Reflection.Missing.Value;

 

            DTE dte = mProgram.mVSTAHookup.DesignTimeEnvironment;

            CommandBars commandBars = dte.CommandBars as CommandBars;

            CommandBarControl control = commandBars["Tools"].Controls.Add(MsoControlType.msoControlButton,

                                                                           1, objMissing, objMissing, true);

            btnLaunchSomething = control as CommandBarButton;

            btnLaunchSomething.Caption = "La&unch Something";

            //btnLaunchSomething.FaceId

            btnLaunchSomething.Click += new _CommandBarButtonEvents_ClickEventHandler(btnLaunchSomething_Click);

        }

 

void btnLaunchSomething_Click(CommandBarButton Ctrl, ref bool CancelDefault)

        {

            WriteLine("Launch Something!");

        }

 

 You can find more information about programming the DTE from the Visual Studio Extensibility forum

Published Thursday, March 15, 2007 6:48 PM by Gary

Comments

  • No Comments
Anonymous comments are disabled