如何向 Visual Studio 加载项添加工具栏?

发布于 2024-10-01 11:33:00 字数 103 浏览 0 评论 0原文

我创建了一个新的 Visual Studio 插件项目。我的项目能够将命令添加到 Visual Stuido 菜单。此代码是由向导创建的。如何将自定义工具栏添加到 Visual Studio?

I have created a new Visual Studio Add-in project. 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸩远一方 2024-10-08 11:33:00

查看 MZ-Tools 上的教程。

“标准”工具栏上的按钮

 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

新工具栏

     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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文