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


IToolControl Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > SystemUI > ESRI.ArcGIS.SystemUI > Interfaces > IT > IToolControl Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (SystemUI)  

IToolControl Interface

Provides access to members that define a toolcontrol.

Product Availability

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

Description

A ToolControl is a Command that acts like a combobox or editbox. Comboboxes let you choose an option from a drop-down list. For example, in ArcMap, you can choose which layer(s) you are selecting features from when working with a map. Editboxes are editable textboxes where you can type in text.

When To Use

The IToolControl interface is implemented by Command objects that act as combobox controls, editbox controls, or other types of controls that can be added to a toolbar. A Command that implements IToolControl passes its window handle to the application. To create a custom ToolControl you would implement both the ICommand and IToolControl interfaces in your class code.

Members

Name Description
Read-only property hWnd The handle of the control.
Method OnDrop Indicates if the drag-drop operation is valid.
Method OnFocus Occurs when the control gains focus.

CoClasses that implement IToolControl

CoClasses and Classes Description
ControlsEditingTargetToolControl (esriControls) Layer in which features you create will be stored.
ControlsEditingTaskToolControl (esriControls) Selects the edit task.
ControlsFlickerRateToolControl (esriControls) Controls the rate (in milliseconds) of the layer flicker.
ControlsGlobeLayerListToolControl (esriControls) Tool control that displays a layer list for the globe.
ControlsLayerListToolControl (esriControls) Tool control that displays a layer list for the focus map.
ControlsMapZoomToolControl (esriControls) Zooms the map by a particular percentage.
ControlsNetworkAnalystLayerToolControl (esriControls) Active Network Dataset Layer.
ControlsPageZoomToolControl (esriControls) Zooms the map layout by a particular percentage.
ControlsSchematicEditTargetControl (esriSchematicControls) Select schematic diagram target.
ControlsSchematicLayoutToolControl (esriSchematicControls) Select schematic diagram layout.
ToolControl (esriFramework) ToolControl CoType.

Remarks

When implementing IToolControl to create a custom tool, use the hWnd property to pass window handle of your control to the application.

For example, if you want your ToolControl to be a simple ComboBox control, put a ComboBox control on a form and then pass the hWnd of the ComboBox control to the ToolControl. If you want your ToolControl to be more complex such as a ComboBox with a label, you can put the ComboBox and Label in a Frame control or PictureBox control, and then pass the hWnd of the Frame or PictureBox to the ToolControl.

Only one instance of a ToolControl can exist within an application framework at any given time. This is because the hWnd property is passed as window handle to the control. To prevent a user from dragging two instances of a ToolControl into an application framework set the ICommand::Category property to an empty string. This will prevent the ToolControl from appearing in the customize dialog.

There is a conflict between ToolControl and MessageBox in .NET. The problem appears when you make the ToolControl the parent of the MessageBox. If you make the application itself the parent of the MessageBox the problem goes away.

Use the following code as a workaround for this issue (C#):

[ DllImport( "User32.dll", EntryPoint="MessageBox", CharSet=CharSet.Auto )]
public static extern int MsgBox( int hWnd, String text, String caption, uint type );

and then:

MsgBox(m_app.hWnd, "Test box", "", 0);

where m_app is the member variable for the current Application.

 

 

See Also

ICommand Interface