com.esri.arcgis.systemUI
Interface ICommand

All Superinterfaces:
Serializable
All Known Implementing Classes:
AddUserMenuItem, AutoCompletePolygonFeatureTool, BaseCommand, BaseTool, Button, ColorCorrectionWindowCommand, CommandHost, ConstructPointsCommand, ContinueFeatureTool, Controls3DAnalystContourTool, Controls3DAnalystSteepestPathTool, ControlsAddDataCommand, ControlsAGOLSignonCommand, ControlsAlignBottomCommand, ControlsAlignCenterCommand, ControlsAlignLeftCommand, ControlsAlignMiddleCommand, ControlsAlignRightCommand, ControlsAlignToMarginsCommand, ControlsAlignTopCommand, ControlsBringForwardCommand, ControlsBringToFrontCommand, ControlsClearSelectionCommand, ControlsContextHelpCommand, ControlsDistributeHorizontallyCommand, ControlsDistributeVerticallyCommand, ControlsDynamicDisplayNavigatorCommand, ControlsEditingAttributeCommand, ControlsEditingClearCommand, ControlsEditingCopyCommand, ControlsEditingCutCommand, ControlsEditingEditTool, ControlsEditingPasteCommand, ControlsEditingSaveCommand, ControlsEditingSketchAbsoluteXYCommand, ControlsEditingSketchChangeLengthCommand, ControlsEditingSketchDeflectionCommand, ControlsEditingSketchDeleteCommand, ControlsEditingSketchDeltaXYCommand, ControlsEditingSketchDirectionCommand, ControlsEditingSketchDirectionLengthCommand, ControlsEditingSketchFinishCommand, ControlsEditingSketchFinishPartCommand, ControlsEditingSketchFinishSquareCommand, ControlsEditingSketchLengthCommand, ControlsEditingSketchParallelCommand, ControlsEditingSketchPerpendicularCommand, ControlsEditingSketchPropertiesCommand, ControlsEditingSketchReplaceCommand, ControlsEditingSketchSegmentDeflectionCommand, ControlsEditingSketchStreamingCommand, ControlsEditingSketchTool, ControlsEditingSnapEdgeCommand, ControlsEditingSnapEndpointCommand, ControlsEditingSnapMidpointCommand, ControlsEditingSnappingCommand, ControlsEditingSnapVertexCommand, ControlsEditingStartCommand, ControlsEditingStopCommand, ControlsEditingTargetToolControl, ControlsEditingTaskToolControl, ControlsEditingVertexDeleteCommand, ControlsEditingVertexInsertCommand, ControlsEditingVertexMoveCommand, ControlsEditingVertexMoveToCommand, ControlsFindRouteCommand, ControlsFlickerRateToolControl, ControlsFullScreenCommand, ControlsGenericGetPositionTool, ControlsGlobeFindCommand, ControlsGlobeFixedLineOfSightTool, ControlsGlobeFixedZoomInCommand, ControlsGlobeFixedZoomOutCommand, ControlsGlobeFlickerCommand, ControlsGlobeFlyTool, ControlsGlobeFullExtentCommand, ControlsGlobeGoToCommand, ControlsGlobeHyperlinkTool, ControlsGlobeIdentifyTool, ControlsGlobeKMLNetworkLinkCommand, ControlsGlobeLayerListToolControl, ControlsGlobeLookAroundTool, ControlsGlobeMeasureTool, ControlsGlobeNavigateTool, ControlsGlobeNavigationModeCommand, ControlsGlobeNorthCommand, ControlsGlobeOpenDocCommand, ControlsGlobeOrbitalFlyTool, ControlsGlobePanDragTool, ControlsGlobePanTool, ControlsGlobeRotateBackCommand, ControlsGlobeRotateClockwiseCommand, ControlsGlobeRotateCounterClockwiseCommand, ControlsGlobeRotateForwardCommand, ControlsGlobeSelectFeaturesTool, ControlsGlobeSpinClockwiseCommand, ControlsGlobeSpinCounterClockwiseCommand, ControlsGlobeSpinFasterCommand, ControlsGlobeSpinSlowerCommand, ControlsGlobeSpinStopCommand, ControlsGlobeSwipeTool, ControlsGlobeTargetCenterTool, ControlsGlobeTargetPanTool, ControlsGlobeTargetZoomTool, ControlsGlobeWalkTool, ControlsGlobeZoomInOutTool, ControlsGroupCommand, ControlsInkAddInkToSketchCommand, ControlsInkClearInkCommand, ControlsInkEraserTool, ControlsInkFindInkCommand, ControlsInkFinishSketchCommand, ControlsInkGenericDrawTool, ControlsInkHighlightTool, ControlsInkOptionsCommand, ControlsInkPenTool, ControlsInkReactivateCommand, ControlsInkRecognizeCommand, ControlsLayerListToolControl, ControlsLayerTransparencyCommand, ControlsMapClearMapRotationCommand, ControlsMapCreateBookmarkCommand, ControlsMapDownCommand, ControlsMapFindCommand, ControlsMapFlickerCommand, ControlsMapFullExtentCommand, ControlsMapGoToCommand, ControlsMapHyperlinkTool, ControlsMapIdentifyTool, ControlsMapLeftCommand, ControlsMapManageBookmarksCommand, ControlsMapMeasureTool, ControlsMapPageDownCommand, ControlsMapPageLeftCommand, ControlsMapPageRightCommand, ControlsMapPageUpCommand, ControlsMapPanTool, ControlsMapRefreshViewCommand, ControlsMapRightCommand, ControlsMapRoamTool, ControlsMapRotateTool, ControlsMapSwipeTool, ControlsMapUpCommand, ControlsMapZoomInFixedCommand, ControlsMapZoomInTool, ControlsMapZoomOutFixedCommand, ControlsMapZoomOutTool, ControlsMapZoomPanTool, ControlsMapZoomToLastExtentBackCommand, ControlsMapZoomToLastExtentForwardCommand, ControlsMapZoomToolControl, ControlsMyPlacesCommand, ControlsNetworkAnalystClosestFacilityCommand, ControlsNetworkAnalystCreateLocationTool, ControlsNetworkAnalystDirectionsCommand, ControlsNetworkAnalystLayerToolControl, ControlsNetworkAnalystLocationAllocationCommand, ControlsNetworkAnalystODCostMatrixCommand, ControlsNetworkAnalystRouteCommand, ControlsNetworkAnalystSelectLocationTool, ControlsNetworkAnalystServiceAreaCommand, ControlsNetworkAnalystSolveCommand, ControlsNetworkAnalystVehicleRoutingProblemCommand, ControlsNetworkAnalystWindowCommand, ControlsNewCircleTool, ControlsNewCurveTool, ControlsNewEllipseTool, ControlsNewFrameTool, ControlsNewFreeHandTool, ControlsNewLineTool, ControlsNewMarkerTool, ControlsNewPolygonTool, ControlsNewRectangleTool, ControlsNudgeDownCommand, ControlsNudgeLeftCommand, ControlsNudgeRightCommand, ControlsNudgeUpCommand, ControlsOpenDocCommand, ControlsPageFocusNextMapCommand, ControlsPageFocusPreviousMapCommand, ControlsPageNewMapCommand, ControlsPagePanTool, ControlsPageZoom100PercentCommand, ControlsPageZoomInFixedCommand, ControlsPageZoomInTool, ControlsPageZoomOutFixedCommand, ControlsPageZoomOutTool, ControlsPageZoomPageToLastExtentBackCommand, ControlsPageZoomPageToLastExtentForwardCommand, ControlsPageZoomPageWidthCommand, ControlsPageZoomToolControl, ControlsPageZoomWholePageCommand, ControlsRedoCommand, ControlsRotateElementTool, ControlsRotateLeftCommand, ControlsRotateRightCommand, ControlsSaveAsDocCommand, ControlsSceneExpandFOVCommand, ControlsSceneFlyTool, ControlsSceneFullExtentCommand, ControlsSceneNarrowFOVCommand, ControlsSceneNavigateTool, ControlsSceneOpenDocCommand, ControlsScenePanTool, ControlsSceneSelectFeaturesTool, ControlsSceneSelectGraphicsTool, ControlsSceneSetObserverTool, ControlsSceneTargetCenterTool, ControlsSceneTargetZoomTool, ControlsSceneZoomInOutTool, ControlsSceneZoomInTool, ControlsSceneZoomOutTool, ControlsSchematicCreateDiagramCommand, ControlsSchematicDecreaseLabelSizeCommand, ControlsSchematicDecreaseSymbolSizeCommand, ControlsSchematicEditTargetControl, ControlsSchematicImportLayerPropertiesCommand, ControlsSchematicIncreaseLabelSizeCommand, ControlsSchematicIncreaseSymbolSizeCommand, ControlsSchematicLayoutExecuteCommand, ControlsSchematicLayoutPropertiesCommand, ControlsSchematicLayoutToolControl, ControlsSchematicMoveElementTool, ControlsSchematicPropagateLayerPropertiesCommand, ControlsSchematicRemoveLinkPointsCommand, ControlsSchematicRestoreDefaultLayerPropertiesCommand, ControlsSchematicSaveAsDiagramCommand, ControlsSchematicSaveEditsCommand, ControlsSchematicSelectEndTool, ControlsSchematicSelectRootTool, ControlsSchematicSquareLinksCommand, ControlsSchematicStartEditCommand, ControlsSchematicStopEditCommand, ControlsSchematicUpdateDiagramCommand, ControlsSelectAllCommand, ControlsSelectByGraphicsCommand, ControlsSelectFeaturesTool, ControlsSelectScreenCommand, ControlsSelectTool, ControlsSendBackwardCommand, ControlsSendToBackCommand, ControlsSnappingEnabledCommand, ControlsSnappingToEdgeCommand, ControlsSnappingToEndCommand, ControlsSnappingToIntersectionCommand, ControlsSnappingToMidpointCommand, ControlsSnappingToPointCommand, ControlsSnappingToTangentCommand, ControlsSnappingToVertexCommand, ControlsSwitchSelectionCommand, ControlsToggleDynamicDisplayCommand, ControlsUndoCommand, ControlsUngroupCommand, ControlsZoomToSelectedCommand, CreateManageRoleMenuItem, CutPolygonsTool, EditTool, EnableGeodatabaseMenuItem, ExcludeUnselectedFeaturesCommand, GlobeDeployCommand, GxAddOleDBConnectionCommand, GxServiceWorkspacesMenuItem, ICommandProxy, IdentifyWindowCommand, ImageAnalysisWindowCommand, InternalButton, InternalButtonComponentTip, InternalComboBox, InternalComboBoxComponentTip, InternalTool, InternalToolComponentTip, InternalToolPalette, LineFeatureTool, MapViewCommandsMenuItems, MirrorFeaturesTool, MissingCommand, OpenTableCommand, PointAtEndOfLineTool, PointFeatureTool, PolygonFeatureTool, ReplaceGeometryTool, ReshapeFeatureTool, RestoreExcludedFeaturesCommand, SelectByCommonValueTool, SketchAngleDistanceCommand, SketchArcCommand, SketchBezierCurveCommand, SketchDistanceDistanceCommand, SketchEndPointArcCommand, SketchIntersectionCommand, SketchMidpointCommand, SketchPointCommand, SketchRightAngleCommand, SketchStraightCommand, SketchTangentCurveCommand, SketchTraceCommand, StretchProportionalCommand, TableContextMenuArrangeItems, TimeSliderWindowCommand, Tool, ToolControl, ToolHost

public interface ICommand
extends Serializable

Provides access to members that define a COM command.

Description

All the commands that are built into the ArcCatalog and ArcMap applications are COM based commands. As a developer, you can create custom commands in development environments that support COM, i.e. Visual Basic, .Net (C# and VB.Net), or C++. COM based commands are distributed in the form of ActiveX DLLs. You can create the following types of commands:

Remarks

Even if you do not have to write code for all the properties and methods on the ICommand interface to meet the requirements of your command design, you must at least create stub code for all of the properties and methods.

When you implement ICommand to create a custom command, you will find that your class constructor and destructor are called more than once per session. Commands are constructed once initially to get information about them, like the name, bitmap, etc and then they are destroyed. When the final, complete construction takes place, the OnCreate method gets called. OnCreate gets called only once, so you can rely on it to perform initialization of member variables. You can check for initialized member variables in the class destructor to find out if OnCreate has been called previously.

When To Use

Use the ICommand interface to query the properties of a COM command or to create your own COM command.

When you are creating a new COM command, you must implement the ICommand interface in your class code. This interface determines the behavior and properties of simple commands such as buttons and menu items. For example, the ICommand interface sets command properties such as caption, name, category, bitmap, statusbar message, tooltip, help context id and help file, enabled state, and checked state. It also defines what action happens when the command is clicked.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
ITool, IToolControl, ICommandSubType

Method Summary
 int getBitmap()
          The bitmap that is used as the icon on this command.
 String getCaption()
          The caption of this command.
 String getCategory()
          The name of the category with which this command is associated.
 int getHelpContextID()
          The help context ID associated with this command.
 String getHelpFile()
          The name of the help file associated with this command.
 String getMessage()
          The statusbar message for this command.
 String getName()
          The name of this commmand.
 String getTooltip()
          The tooltip for this command.
 boolean isChecked()
          Indicates if this command is checked.
 boolean isEnabled()
          Indicates if this command is enabled.
 void onClick()
          Occurs when this command is clicked.
 void onCreate(Object hook)
          Occurs when this command is created.
 

Method Detail

isEnabled

boolean isEnabled()
                  throws IOException,
                         AutomationException
Indicates if this command is enabled.

Remarks

When implementing ICommand to create a custom command, add some logic to the Enabled property to specify in what state the application should be in for the command to be enabled.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The enabled
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

isChecked

boolean isChecked()
                  throws IOException,
                         AutomationException
Indicates if this command is checked.

Remarks

The Checked property indicates the state of this Command. If a command item appears depressed on a commandbar, the command is checked. The active tool will appear checked. Also commands that serve as a toggle will be checked when that toggle is on.
A system event is periodically called to set the state of the commands on the commandbars indicating which ones are checked.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The checked
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getName

String getName()
               throws IOException,
                      AutomationException
The name of this commmand.

Remarks

The Name property of a command is a programmatic identifying name string. By convention, a command's name should include its category name. The format of the Name string should be <Category>_<Caption>. For example, the name of the builtin ArcMap command About ArcMap is "Help_About". Since it is an identifier of the command, the Name property should not be localized.

When implementing ICommand to create a custom command, use the Name property to set the internal name of this command.

Note, the Caption property of a command is the string that appears when the command is placed on a command bar.

Example:

 

public String getName () {
     return "MyCustomTool_MyTool";
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The name
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCaption

String getCaption()
                  throws IOException,
                         AutomationException
The caption of this command.

Remarks

The Caption property of a command is the string that appears when the command is placed on a command bar.

When implementing ICommand to create a custom command, use the Caption property to set the caption of the command.

Example:

public String getCaption() {
     return "MyTool";
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The caption
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getTooltip

String getTooltip()
                  throws IOException,
                         AutomationException
The tooltip for this command.

Remarks

When implementing ICommand to create a custom command, use the ToolTip property to set the string that appears in the screen tip when the mouse hovers over the command.

Example:

public String getTooltip () {
    return "MyTool";
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The tooltip
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getMessage

String getMessage()
                  throws IOException,
                         AutomationException
The statusbar message for this command.

Remarks

When implementing ICommand to create a custom command, use the Message property to set the message string that appears in the statusbar of the application when the mouse passes over the command.

Example:

public String getMessage() {
     return "This is my custom tool";
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The message
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getHelpFile

String getHelpFile()
                   throws IOException,
                          AutomationException
The name of the help file associated with this command.

Description

The HelpFile property is used to specify the name of the help file that contains the context sensitive help topic for your custom command.

Remarks

If you set both the HelpFile and HelpContextID properties, then an end-user of your command can use the "What's This?" command in ArcMap or ArcCatalog to get help on your command. Note, if you want your What's This help to look and behave the same as the standard ArcGIS commands, then you should create a WinHelp file instead of a HTMLHelp file.

If you have a WinHelp file (*.hlp), set ICommand_HelpFile to the name of the help file containing the topic that describes the command and set ICommand_HelpContextID to the topic ID's mapped numeric value. The topic ID is the so-called # footnote in the RTF file you include in your WinHelp file. You can use Help Workshop to add this numeric value by opening the HPJ file, clicking Map and then clicking Add (to add the mapping for an individual topic). See the help topic "To enable a program to display an individual Help topic" in the Help Workshop's help file.

If you have an HTMLHelp file (*.chm) the procedure is similar; specifiy the .chm file as ICommand_HelpFile and the mapped numeric value as ICommand_HelpContextID. Popup topics are problematic with HTMLHelp, but the help topic will display in a default or user-defined window.

As part of your deployment strategy register the name of the WinHelp file (*.hlp) as a new string value in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Help

Or if you're working with a HTMLHelp file (*.chm) register its name as a new string value in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\HTMLHelp.

Note, if you want to create a custom command that launches your help system, you can call an entire help file and/or use the functionality of the appropriate Help APIs by declaring and using the Windows API WinHelp() function or HTMLHelp() function.

Once you have one of these help functions declared, the OnClick event of your command could call the help function.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The helpFile
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
See Also:
ICommand.getHelpContextID()

getHelpContextID

int getHelpContextID()
                     throws IOException,
                            AutomationException
The help context ID associated with this command.

Description

The HelpContextID property is used to specify the mapped numeric value of the topic ID of the context sensitive help topic for your custom command. Specify the name of your help file in the HelpFile property.

Remarks

If you set both the HelpFile and HelpContextID properties, then an end-user of your command can use the "What's This?" command in ArcMap or ArcCatalog to get help on your command. Note, if you want your What's This help to look and behave the same as the standard ArcGIS commands, then you should create a WinHelp file instead of a HTMLHelp file.

If you have a WinHelp file (*.hlp), set ICommand_HelpFile to the name of the help file containing the topic that describes the command and set ICommand_HelpContextID to the topic ID's mapped numeric value. The topic ID is the so-called # footnote in the RTF file you include in your WinHelp file. You can use Help Workshop to add this numeric value by opening the HPJ file, clicking Map and then clicking Add (to add the mapping for an individual topic). See the help topic "To enable a program to display an individual Help topic" in the Help Workshop's help file.

If you have an HTMLHelp file (*.chm) the procedure is similar; specifiy the
.chm file as ICommand_HelpFile and the mapped numeric value as
ICommand_HelpContextID. Popup topics are problematic with HTMLHelp, but the help topic will display in a default or user-defined window.

As part of your deployment strategy register the name of the WinHelp file (*.hlp) as a new string value in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Help

Or if you're working with a HTMLHelp file (*.chm) register its name as a new string value in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\HTMLHelp.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The helpID
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
See Also:
ICommand.getHelpFile()

getBitmap

int getBitmap()
              throws IOException,
                     AutomationException
The bitmap that is used as the icon on this command.

Remarks

When implementing ICommand to create a custom command, use the Bitmap property to set the bitmap to be used as the icon on this command. In your Visual Basic project for this command, the bitmap can be stored in a resource file or in a PictureBox control on a form.

You must use a Bitmap file (.bmp) for the Bitmap property; Icon files (.ico) are not supported. Bitmap files should be 16 X 16 pixels. The color of the upper left pixel of the bitmap is treated as the transparent color. For example, if the upper left pixel of the bitmap is red, then all of the red pixels in the bitmap will be converted to transparent.

When a command is put on a toolbar, the command is displayed with the bitmap only by default; the display type is set to Image Only (ICommandItem::Style = esriCommandStyleIconOnly). When a command is put on a menu, the command is displayed with the bitmap and caption by default; the display type is set to Image and Text (ICommandItem::Style = esriCommandStyleIconAndText). However, if the Bitmap property is not set for this command, then the command will be displayed with the caption only by default when it is put on a toolbar or menu; the display type is set to Text Only (ICommandItem::Style = esriCommandStyleTextOnly).

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

When implementing ICommand to create a custom command, there is no need to implement this method. In the custom Java Command class, set the bitmapPath String to the physical location of the bitmap file to be used on the toolbar.

bitmapPath = "/images/mybitmap.bmp";

You must use a Bitmap file (.bmp); Icon files (.ico) are not supported. Bitmap files should be 16 X 16 pixels. The color of the upper left pixel of the bitmap is treated as the transparent color. For example, if the upper left pixel of the bitmap is red, then all of the red pixels in the bitmap will be converted to transparent.

When a command is put on a toolbar, the command is displayed with the bitmap only by default; the display type is set to Image Only (esriCommandStyles.esriCommandStyleIconOnly). When a command is put on a menu, the command is displayed with the bitmap and caption by default; the display type is set to Image and Text (esriCommandStyles.esriCommandStyleIconAndText). However, if the Bitmap property is not set for this command, then the command will be displayed with the caption only by default when it is put on a toolbar or menu; the display type is set to Text Only (esriCommandStyles.esriCommandStyleTextOnly).

Returns:
The bitmap (A COM typedef)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCategory

String getCategory()
                   throws IOException,
                          AutomationException
The name of the category with which this command is associated.

Remarks

Category determines where the command will appear in the Commands panel of the Customize dialog.

When implementing ICommand to create a custom command, use the Category property to set the category of this command.

Example:

public String getCategory() {
   return "MyCustomTool";
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Returns:
The categoryName
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

onCreate

void onCreate(Object hook)
              throws IOException,
                     AutomationException
Occurs when this command is created.

Description

hook is a reference to an IApplication object or any of the Controls.

Remarks

The OnCreate method gives the command a hook into the application.

When implementing ICommand to create a custom command, use the OnCreate method to get a hook to the application.

When you implement ICommand to create a custom command, you will find that your class constructor and destructor are called more than once per session. Commands are constructed once initially to get information about them, like the name, bitmap, etc and then they are destroyed. When the final, complete construction takes place, the OnCreate method gets called. OnCreate gets called only once, so you can rely on it to perform initialization of member variables. You can check for initialized member variables in the class destructor to find out if OnCreate has been called previously.

Example:

Object buddyControl = null;

MapControl mapControl = null; 
 
//If your buddy control is of type mapcontrol
 
public void onCreate(Object hook) {
      try { 
      // The hook argument is an instance of control to which this tool is added. 
      // Normally toolbar control.          
      ToolbarControl toolbarControl = new ToolbarControl(hook); 
      //Get the buddy control to which the toolbarcontrol is associated to.         
      buddyControl = toolbarControl.getBuddy();
      mapControl = new MapControl(buddyControl);
       }
      catch (IOException ex) {
      }
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Parameters:
hook - A reference to another Automation Object (IDispatch) (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
See Also:
IApplication

onClick

void onClick()
             throws IOException,
                    AutomationException
Occurs when this command is clicked.

Remarks

When implementing ICommand to create a custom command, write the code that performs the action when the command is clicked in the OnClick method.

Example:

public void onClick() {     
   //In this example, a message is displayed in console.     
   System.out.println("Clicked on my command");
}

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.