我创建了一个新的 Visual Studio 加载项项目。我的项目能够将命令添加到 Visual Stuido 菜单。此代码由向导创建。如何将自定义工具栏添加到 Visual Studio?
问问题
2623 次
1 回答
7
查看关于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
于 2010-11-09T15:47:32.220 回答