Partager via


OleMenuCommandService.GlobalInvoke Method (CommandID, Object)

Can be used to invoke any command within Visual Studio.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)

Syntax

'Déclaration
Public Overrides Function GlobalInvoke ( _
    commandID As CommandID, _
    arg As Object _
) As Boolean
'Utilisation
Dim instance As OleMenuCommandService
Dim commandID As CommandID
Dim arg As Object
Dim returnValue As Boolean

returnValue = instance.GlobalInvoke(commandID, _
    arg)
public override bool GlobalInvoke(
    CommandID commandID,
    Object arg
)
public:
virtual bool GlobalInvoke(
    CommandID^ commandID, 
    Object^ arg
) override
abstract GlobalInvoke : 
        commandID:CommandID * 
        arg:Object -> bool 
override GlobalInvoke : 
        commandID:CommandID * 
        arg:Object -> bool 
public override function GlobalInvoke(
    commandID : CommandID, 
    arg : Object
) : boolean

Parameters

Return Value

Type: System.Boolean
true if the invocation succeeded; otherwise, false.

Remarks

Visual Studio uses a built-in search hierarchy to search for the requested command. The search pattern favors the current document window and then moves out to broader focus.

Some commands may take optional arguments, and they can be passed to the handler of the command via the arg parameter of GlobalInvoke. For instance, a Find command may accept a string representing the text to find. An OpenFile command may take a file name as an argument. If a command can use an optional argument, it defines what is expected and should document how one would invoke the command with optional arguments.

.NET Framework Security

See Also

Reference

OleMenuCommandService Class

OleMenuCommandService Members

GlobalInvoke Overload

Microsoft.VisualStudio.Shell Namespace