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


IToolbarControlDefault.CurrentTool Property (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Controls)  

IToolbarControlDefault.CurrentTool Property

The current tool of the buddy.

[Visual Basic .NET]
Public Property CurrentTool As ITool
[C#]
public ITool CurrentTool {get; set;}
[C++]
HRESULT get_CurrentTool(
  ITool** pVal
);
[C++]
HRESULT putref_CurrentTool(
  ITool* pVal
);
[C++]

Parameters pVal [out, retval]
pVal is a parameter of type ITool pVal [in]
pVal is a parameter of type ITool

Product Availability

Available with ArcGIS Engine.

Description

This is a shortcut to the CurrentTool of the Buddy. The Buddy implements the IToolbarBuddy interface that has a CurrentTool property. If no Buddy is set the CurrentTool returns Nothing.

On a ToolbarControl there is only ever one CurrentTool, and this is the item that appears 'pushed in'. If another tool is selected it becomes the new CurrentTool and the previous tool is deactivated.

If multiple ToolbarControls share the same CommandPool and have the same Buddy the CurrentTool is synchronised through the Buddy so only one item on all the ToolbarControl's will be the CurrentTool.

Errors Returned

1039 800A040F: The supplied buddy is not a supported object 

Remarks

Always check that the Buddy has been set, before setting the CurrentTool or the method will fail.

When the CurrentTool is set the following events occur:

  1. The ITool::Deactivate event is triggered on the 'old' CurrentTool if one was set. If this event returns false a trappable error ocurrs. If this event returns true the 'old' CurrentTool is removed and replaced.
  2. The ICommand::OnClick event is triggered on the 'new' CurrentTool and its cursor is picked up.

Within an ITool implementation it is recommended that the ITool::Deactivate event returns true. This allows a 'new' CurrentTool to be set, and allows the release of the CurrentTool when an application is shutting down.

See Also

IToolbarControlDefault Interface

.NET Snippets

Add Editing Commands to ToolbarControl