Commands2.AddNamedCommand2 方法

更新:2007 年 11 月

创建命名命令,该命令由环境保存,并且在下次环境启动时(无论是否加载外接程序)可用。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
Function AddNamedCommand2 ( _
    AddInInstance As AddIn, _
    Name As String, _
    ButtonText As String, _
    Tooltip As String, _
    MSOButton As Boolean, _
    Bitmap As Object, _
    ByRef ContextUIGUIDs As Object(), _
    vsCommandStatusValue As Integer, _
    CommandStyleFlags As Integer, _
    ControlType As vsCommandControlType _
) As Command
用法
Dim instance As Commands2
Dim AddInInstance As AddIn
Dim Name As String
Dim ButtonText As String
Dim Tooltip As String
Dim MSOButton As Boolean
Dim Bitmap As Object
Dim ContextUIGUIDs As Object()
Dim vsCommandStatusValue As Integer
Dim CommandStyleFlags As Integer
Dim ControlType As vsCommandControlType
Dim returnValue As Command

returnValue = instance.AddNamedCommand2(AddInInstance, _
    Name, ButtonText, Tooltip, MSOButton, _
    Bitmap, ContextUIGUIDs, vsCommandStatusValue, _
    CommandStyleFlags, ControlType)
Command AddNamedCommand2(
    AddIn AddInInstance,
    string Name,
    string ButtonText,
    string Tooltip,
    bool MSOButton,
    Object Bitmap,
    ref Object[] ContextUIGUIDs,
    int vsCommandStatusValue,
    int CommandStyleFlags,
    vsCommandControlType ControlType
)
Command^ AddNamedCommand2(
    [InAttribute] AddIn^ AddInInstance, 
    [InAttribute] String^ Name, 
    [InAttribute] String^ ButtonText, 
    [InAttribute] String^ Tooltip, 
    [InAttribute] bool MSOButton, 
    [InAttribute] Object^ Bitmap, 
    [InAttribute] array<Object^>^% ContextUIGUIDs, 
    [InAttribute] int vsCommandStatusValue, 
    [InAttribute] int CommandStyleFlags, 
    [InAttribute] vsCommandControlType ControlType
)
function AddNamedCommand2(
    AddInInstance : AddIn, 
    Name : String, 
    ButtonText : String, 
    Tooltip : String, 
    MSOButton : boolean, 
    Bitmap : Object, 
    ContextUIGUIDs : Object[], 
    vsCommandStatusValue : int, 
    CommandStyleFlags : int, 
    ControlType : vsCommandControlType
) : Command

参数

  • Name
    类型:System.String

    必需。您的新命令名称的缩写形式。AddNamedCommand2 使用前缀 Addins.Progid. 来创建一个唯一的名称。

  • ButtonText
    类型:System.String

    必需。在命令绑定到以名称而不是以图标显示的按钮时使用的名称。

  • Tooltip
    类型:System.String

    必需。当用户将鼠标指针悬停在任何绑定到新命令的控件上时所显示的文本。

  • MSOButton
    类型:System.Boolean

    必需。指示指定命令的按钮图片是否是 Office 图片。True = 按钮。如果 MSOButton 为 False,则 Bitmap 为 Visual C++ 资源 DLL 中的 16x16 位图资源(而不是图标资源)的 ID,此资源 DLL 必须驻留在具有语言的区域设置标识符(英语为 2052)的文件夹中。

  • Bitmap
    类型:System.Object

    可选。在按钮上显示的位图的 ID。

  • ContextUIGUIDs
    类型:array<System.Object[]%

    可选。GUID 的 SafeArray,它确定哪些环境上下文(即调试模式、设计模式等)启用此命令。请参见 vsCommandDisabledFlags

  • vsCommandStatusValue
    类型:System.Int32

    可选。确定当您提供了 ContextUIGUIDs 而当前它们都不活动时,此命令的禁用状态是不可见还是灰色的。

  • CommandStyleFlags
    类型:System.Int32

    vsCommandStyle 枚举中的值。控制为该命令添加的任何 UI 的视觉样式。

返回值

类型:EnvDTE.Command

已创建的命名命令。

权限

另请参见

参考

Commands2 接口

Commands2 成员

EnvDTE80 命名空间