共用方式為


ViewFilter.ExecCommand Method

Executes the specified command.

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

Syntax

'宣告
Protected Overridable Function ExecCommand ( _
    ByRef guidCmdGroup As Guid, _
    nCmdId As UInteger, _
    nCmdexecopt As UInteger, _
    pvaIn As IntPtr, _
    pvaOut As IntPtr _
) As Integer
'用途
Dim guidCmdGroup As Guid
Dim nCmdId As UInteger
Dim nCmdexecopt As UInteger
Dim pvaIn As IntPtr
Dim pvaOut As IntPtr
Dim returnValue As Integer

returnValue = Me.ExecCommand(guidCmdGroup, _
    nCmdId, nCmdexecopt, pvaIn, pvaOut)
protected virtual int ExecCommand(
    ref Guid guidCmdGroup,
    uint nCmdId,
    uint nCmdexecopt,
    IntPtr pvaIn,
    IntPtr pvaOut
)
protected:
virtual int ExecCommand(
    Guid% guidCmdGroup, 
    unsigned int nCmdId, 
    unsigned int nCmdexecopt, 
    IntPtr pvaIn, 
    IntPtr pvaOut
)
abstract ExecCommand : 
        guidCmdGroup:Guid byref * 
        nCmdId:uint32 * 
        nCmdexecopt:uint32 * 
        pvaIn:IntPtr * 
        pvaOut:IntPtr -> int 
override ExecCommand : 
        guidCmdGroup:Guid byref * 
        nCmdId:uint32 * 
        nCmdexecopt:uint32 * 
        pvaIn:IntPtr * 
        pvaOut:IntPtr -> int 
protected function ExecCommand(
    guidCmdGroup : Guid, 
    nCmdId : uint, 
    nCmdexecopt : uint, 
    pvaIn : IntPtr, 
    pvaOut : IntPtr
) : int

Parameters

  • guidCmdGroup
    Type: System.Guid%
    [in] The GUID of the command group.
  • nCmdId
    Type: System.UInt32
    [in] The specific ID of the command from the command group. This identifies the command to execute.
  • nCmdexecopt
    Type: System.UInt32
    [in] Additional parameters for the command (packed into a 32-bit value).
  • pvaIn
    Type: System.IntPtr
    [in] An unmarshaled pointer to a Variant object holding any parameters required by the command. This can be a null value indicating there are no additional parameters.
  • pvaOut
    Type: System.IntPtr
    [in, out] An unmarshaled pointer to a Variant object to hold the result of the command, if any.

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Remarks

This method is called to execute a particular command. In general, this method should first call the HandlePreExec method, then some sort of execution method, and finally the HandlePostExec method. If the command is not handled by any of these, the command should be passed on to the next command target.

The base method first calls the IsExpansionUIActive method to determine if an expansion user interface (UI) is active. If so, the base method immediately passes the command on to the next command target and returns the result. Otherwise, the base method gets the ExpansionProvider object and, if that object exists, calls its HandlePreExec method. It the ExpansionProvider's HandlePreExec method indicates the command was handled, the base method returns immediately.

If neither the expansion UI nor the ExpansionProvider is active, the base method calls the HandlePreExec method. If HandlePreExec does not handle the command, the command is passed on to the next command target. The base method then calls the HandlePostExec method on the ExpansionProvider object (if it exists) before calling the HandlePostExec method.

The base method also handles the special case of an Enter key pressed while a completion set is open but nothing is selected in the set; in this case, the Enter key should be added to the source file and this is done by passing the command to the next command target a second time (the first time closes the completion set and consumes the Enter key).

This method is typically called from the base class's internal implementation of the Exec method on the IOleCommandTarget interface.

.NET Framework Security

See Also

Reference

ViewFilter Class

ViewFilter Members

Microsoft.VisualStudio.Package Namespace