Partager via


Commands2.AddNamedCommand2, méthode

Crée une commande nommée qui est enregistrée par l'environnement et qui sera disponible au prochain démarrage de cet environnement, même si le complément n'est pas chargé au démarrage de l'environnement.

Espace de noms :  EnvDTE80
Assembly :  EnvDTE80 (dans EnvDTE80.dll)

Syntaxe

'Déclaration
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
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
)
abstract AddNamedCommand2 : 
        AddInInstance:AddIn * 
        Name:string * 
        ButtonText:string * 
        Tooltip:string * 
        MSOButton:bool * 
        Bitmap:Object * 
        ContextUIGUIDs:Object[] byref * 
        vsCommandStatusValue:int * 
        CommandStyleFlags:int * 
        ControlType:vsCommandControlType -> Command 
function AddNamedCommand2(
    AddInInstance : AddIn, 
    Name : String, 
    ButtonText : String, 
    Tooltip : String, 
    MSOButton : boolean, 
    Bitmap : Object, 
    ContextUIGUIDs : Object[], 
    vsCommandStatusValue : int, 
    CommandStyleFlags : int, 
    ControlType : vsCommandControlType
) : Command

Paramètres

  • AddInInstance
    Type : EnvDTE.AddIn
    Obligatoire.L'objet AddIn ajoute la nouvelle commande.
  • Name
    Type : System.String
    Obligatoire.Forme courte du nom de votre nouvelle commande.AddNamedCommand2 utilise la préface Addins.Progid. pour créer un nom unique.
  • ButtonText
    Type : System.String
    Obligatoire.Nom à utiliser si la commande est liée à un bouton qui s'affiche sous la forme d'un nom et non d'une icône.
  • Tooltip
    Type : System.String
    Obligatoire.Texte qui s'affiche lorsqu'un utilisateur arrête le pointeur de la souris sur un contrôle lié à la nouvelle commande.
  • MSOButton
    Type : System.Boolean
    Obligatoire.Indique comment le paramètre bitmap est interprété.
    Si la valeur est true, Bitmap est l'ID d'un bitmap de Microsoft Office.
    Si MSOButton est false, Bitmap peut être l'une des valeurs suivantes :
    - Un Bitmap.
    - Un Icon.
    - IPicture
    - L'ID d'une ressource bitmap 16x16 (et non d'une ressource icône) qui est fournie par le complément.Visual Studio recherchera d'abord dans la DLL satellite du complément.Si la ressource est introuvable, la DLL du complément sera recherchée.
  • Bitmap
    Type : System.Object
    Facultatif.ID d'une bitmap à afficher sur le bouton.Consultez MSOButton.
  • ContextUIGUIDs
    Type : array<System.Object[]%
    Facultatif.SafeArray d'identificateurs GUID qui détermine quels contextes d'environnement (mode débogage, mode design, etc.) affichent la commande.Consultez vsCommandDisabledFlags.
  • vsCommandStatusValue
    Type : System.Int32
    Facultatif.Détermine si la commande en état désactivé est invisible ou grisée lorsque vous fournissez un ContextUIGUIDs et qu'aucun des identificateurs n'est actuellement actif.
  • CommandStyleFlags
    Type : System.Int32
    Facultatif.Détermine l'état de la commande lorsque vous fournissez un ContextUIGUIDs et qu'aucun des contextes spécifiés n'est actuellement actif.Ce paramètre doit toujours inclure vsCommandStatusSupported.S'il inclut également vsCommandStatusEnabled, la commande sera activée.

Valeur de retour

Type : EnvDTE.Command
Commande nommée qui a été créée.

Notes

Pour plus d'informations sur la manière d'obtenir des valeurs d'ID de bitmap de boutons MSO, consultez Listing Button Faces in the Command Bar for the Microsoft Office System (éventuellement en anglais).

Les compléments peuvent changer ultérieurement le nom ButtonText en répondant à la méthode QueryStatus. Si le texte commence par "#", le reste de la chaîne est un entier qui représente un identificateur de ressource dans la DLL satellite enregistrée du complément.

Les paramètres ContextUIGUIDs et vsCommandStatusValue sont utilisés lorsque le complément n'est pas chargé et ne peut donc pas répondre à la méthode QueryStatus. Si ContextUIGUIDs est vide, la commande est activée jusqu'à ce que le complément soit chargé et puisse répondre à QueryStatus.

Le complément peut recevoir une notification d'invocation par l'intermédiaire de l'interface IDTCommandTarget. Un bouton peut être ajouté en utilisant la méthode OnConnection de l'interface IDTExtensibility2.

Sécurité .NET Framework

Voir aussi

Référence

Commands2 Interface

EnvDTE80, espace de noms