Visual Studio 2017 extended development (1) Add a menu to the Visual Studio menu bar, visual Studio menu bar

Source: Internet
Author: User

Visual Studio 2017 extended development (1) Add a menu to the Visual Studio menu bar, visual Studio menu bar

Recently, I have been involved in the development of visual studio 2017 extensions. I hereby record it to urge myself to gain a deep understanding of its principles.

Start to develop Visual Studio extensions. Here I have installed visual studio 2017. Remember to check visual studio extension development when installing Visual Studio.

Create a project

Open the compiler, file → create a Project, template → Visual C # → Extensibility select VSIX Project. Create a Project.

Add custom commands

Right-click a project and add a new project. Visual C # item → Extensibility → Custom Command

 

Find the menu name for modifying the CommandPackage. vsct file.

In the Commands node.

<Buttons> <! -- To define a menu group you have to specify its ID, the parent menu and its display priority. the command is visible and enabled by default. if you need to change the visibility, status, etc, you can use the CommandFlag node. you can add more than one CommandFlag node e.g.: <CommandFlag> DefaultInvisible </CommandFlag> <CommandFlag> DynamicVisibility </CommandFlag> If you do not want an image next to your command, remove the Icon node/> --> <Button guid = "guidCommandPackageCmdSet" id = "CommandId" priority = "0x0100" type = "Button"> <Parent guid = "guidCommandPackageCmdSet" id = "MyMenuGroup"/> <Icon guid = "guidImages" id = "BMP pic1"/> <Strings> <ButtonText> test menu </ButtonText> </Strings> </Button> </Buttons>

Then open the Command. cs file. Drop down to the end.

Private void MenuItemCallback (object sender, EventArgs e) {string message = "Hello Word"; string title = "test"; // Show a message box to prove we were here VsShellUtilities. showMessageBox (this. serviceProvider, message, title, OLEMSGICON. OLEMSGICON_INFO, OLEMSGBUTTON. OLEMSGBUTTON_ OK, OLEMSGDEFBUTTON. OLEMSGDEFBUTTON_FIRST );}

 

Result

Run, A New Visual Studio is opened, which is the debugging mode.

Click the tool to view the expanded menu.

 

Click test menu

 

 

 

This article is only my learning record. I should continue to write it later. If it is helpful to you, move your mouse and give me a thumbs up at the bottom right. Your support is my greatest motivation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.