
386Microsoft Visual Studio 2010: A Beginner’s Guide
(int)vsCommandStyle
.vsCommandStylePictAndText, vsCommandControlType
.vsCommandControlTypeButton);
if((command != null) && (toolsPopup != null))
{
command.AddControl( toolsPopup.CommandBar, 1);
}
}
catch(System.ArgumentException)
{
}
}
}
VB:
Public Sub OnConnection(
ByVal application As Object,
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object,
ByRef custom As Array) Implements IDTExtensibility2.OnConnection _applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
If connectMode = ext_ConnectMode.ext_cm_UISetup Then
Dim commands As Commands2 =
CType(_applicationObject.Commands, Commands2)
Dim toolsMenuName As String = "Tools"
Dim commandBars As CommandBars = CType(_applicationObject.CommandBars, CommandBars)
Dim menuBarCommandBar As CommandBar = commandBars.Item("MenuBar")
Dim toolsControl As CommandBarControl = menuBarCommandBar.Controls.Item(toolsMenuName)
Dim toolsPopup As CommandBarPopup = CType(toolsControl, CommandBarPopup)
Try