开发者

How to add a toolbar to a Visual Studio add-in?

开发者 https://www.devze.com 2023-01-24 07:31 出处:网络
I have created a new Visual Studio Add-in project开发者_JAVA百科. My project is able to add commands to Visual Stuido menu. This code is created by wizard. How can I add my custom toolbar to Visual St

I have created a new Visual Studio Add-in project开发者_JAVA百科. My project is able to add commands to Visual Stuido menu. This code is created by wizard. How can I add my custom toolbar to Visual Studio?


Check out tutorial on MZ-Tools.

Button on the "Standard" toolbar

 commandBars = DirectCast(<dte instance>.CommandBars, CommandBars)
 standardCommandBar = commandBars.Item(VS_STANDARD_COMMANDBAR_NAME)

 ' Add a button to the built-in "Standard" toolbar
 myStandardCommandBarButton = DirectCast(myCommand.AddControl(standardCommandBar, _
 standardCommandBar.Controls.Count + 1), CommandBarButton)

 ' Change some button properties
 myStandardCommandBarButton.Caption = MY_COMMAND_CAPTION
 myStandardCommandBarButton.Style = MsoButtonStyle.msoButtonIcon ' It could be also        msoButtonIconAndCaption
 myStandardCommandBarButton.BeginGroup = True ' Separator line above button

New toolbar

     commandBars = DirectCast(<dte instance>.CommandBars, CommandBars)

     ' Add a new toolbar 
     myTemporaryToolbar = commandBars.Add(MY_TEMPORARY_TOOLBAR_CAPTION, _
        MsoBarPosition.msoBarTop, System.Type.Missing, True)

     ' Add a new button on that toolbar
     myToolBarButton = DirectCast(myCommand.AddControl(myTemporaryToolbar, _
        myTemporaryToolbar.Controls.Count + 1), CommandBarButton)

     ' Change some button properties
     myToolBarButton.Caption = MY_COMMAND_CAPTION
     myToolBarButton.Style = MsoButtonStyle.msoButtonIconAndCaption ' It could be also msoButtonIcon

     ' Make visible the toolbar
     myTemporaryToolbar.Visible = True
0

精彩评论

暂无评论...
验证码 换一张
取 消