This document is archived and information here might be outdated.  Recommended version.


ICommandPoolEdit.AddCommand Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Controls)  

ICommandPoolEdit.AddCommand Method

Adds the specified command to the command pool. If the command already exists its usage count incremented by 1.

[Visual Basic .NET]
Public Sub AddCommand ( _
    ByVal Command As ICommand, _
    ByVal pUID As UID _
)
[C#]
public void AddCommand (
    ICommand Command,
    UID pUID
);
[C++]
HRESULT AddCommand(
  ICommand* Command,
  IUID* pUID
);
[C++]

Parameters Command [in]
Command is a parameter of type ICommand pUID [in]
pUID is a parameter of type IUID

Product Availability

Available with ArcGIS Engine.

Description

If a UID object is specified and the command object is nothing, the method searches the CommandPool for the given UID. If the UID is found its UsageCount is incremented by 1. If the UID is not found a new command is created and added to the CommandPool with a UsageCount of 1. 

If a command object is specified and the UID object is nothing, the command is added to the CommandPool with a UsageCount of 1.

If a  UID object and a command object are specified, the method searches the CommandPool for the given UID. If the UID is found its UsageCount is incremented by 1. If the UID is not found the specified command is added to the CommandPool with a UsageCount of 1. 

Errors Returned

1034 800a040a: The supplied command is invalid
1035 800a040b: The subtype specified for the command (possibly in a UID object) is invalid or out of range

Remarks

Typically the AddUID method should be used as the method to add commands that implement the ICommandSubType interface. If the AddCommand method is used the IUID::SubType property must be set.

[C#]
ICommandPoolEdit commandPoolEdit=(ICommandPoolEdit) axToolbarControl1.CommandPool;

//Passing a UID
UID uID=new UIDClass();
uID.Value="esriControls.ControlsMapFullExtentCommand";
commandPoolEdit.AddCommand(null, uID);

//Passing a Command
ICommand command=new ControlsMapFullExtentCommandClass();
commandPoolEdit.AddCommand(command, null);

//Passing a UID and Command
uID.Value="esriControls.ControlsMapFullExtentCommand";
command=new ControlsMapFullExtentCommandClass();
commandPoolEdit.AddCommand(command, uID);

//Passing a UID (ICommandSubType)
uID.Value="MyCommandSubTypes.MyCommands";
uID.SubType=2;
commandPoolEdit.AddCommand(null, uID);
[Visual Basic .NET]
Dim pCommandPoolEdit As ICommandPoolEdit
pCommandPoolEdit=AxToolbarControl1.CommandPool

'Passing a UID
Dim pUid As New UIDClass
pUid.Value="esriControls.ControlsMapFullExtentCommand"
pCommandPoolEdit.AddCommand(Nothing, pUid)

'Passing a Command
Dim pCommand As ICommand
pCommand=New ControlsMapFullExtentCommandClass
pCommandPoolEdit.AddCommand(pCommand, Nothing)

'Passing a UID and Command
pUid.Value="esriControls.ControlsMapFullExtentCommand"
pCommand=New ControlsMapFullExtentCommand
pCommandPoolEdit.AddCommand(pCommand, pUid)

'Passing a UID (ICommandSubType)
pUid.Value="MyCommandSubTypes.MyCommands"
pUid.SubType=2
pCommandPoolEdit.AddCommand(Nothing, pUid)

See Also

ICommandPoolEdit Interface