18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH THE ARCGIS CONTROLS<br />

• A command item or tool control implementing both the ICommand and<br />

IToolControl interfaces. This is typically a user interface component, such as a<br />

Listbox or ComboBox, hosted on the ToolbarControl. The ToolbarControl hosts a<br />

small window supplied by a window handle from the IToolControl::hWnd<br />

property. Only a single instance of a particular tool control can be added to<br />

the ToolbarControl.<br />

Commands can be added to ToolbarControl in two ways: by specifying a UID<br />

object that uniquely identifies a command (using a Globally Unique Identifier, or<br />

GUID) or by supplying an instance of an existing Command object to the AddItem<br />

method. Where possible, commands should be added to the ToolbarControl by<br />

specifying a UID. If a UID is supplied, the ToolbarControl can identify whether<br />

this command has previously been added and, if so, can reuse the previous instance<br />

of the command. When an existing instance of a Command object is added<br />

to the ToolbarControl, there is no unique identifier for the command, and multiple<br />

instances of the same command can exist on the ToolbarControl.<br />

ToolbarItem<br />

A ToolbarItem is a single command or menu hosted on a ToolbarControl or<br />

ToolbarMenu. The IToolbarItem interface has properties to determine the appearance<br />

of the item to the end user, for example, whether the item has a vertical line<br />

to its left signifying that it begins a Group and whether the Style of the item<br />

displays with a bitmap, a caption, or both. The Command and Menu properties<br />

return the actual command or menu that the ToolbarItem represents.<br />

Updating commands<br />

By default, the ToolbarControl updates itself automatically every one-half second<br />

to ensure that the appearance of each ToolbarItem hosted on the ToolbarControl is<br />

synchronized with the Enabled, Bitmap, and Caption properties of its underlying<br />

command. Changing the UpdateInterval property can alter the frequency of the<br />

update. An UpdateInterval of 0 will stop any updates from happening automatically,<br />

and you must call the Update method programmatically to refresh the state<br />

of each ToolbarItem.<br />

The first time the Update method is called in an application, the<br />

ToolbarControl will check whether the ICommand::OnCreate method of<br />

each ToolbarItem’s underlying command has been called. If the method<br />

has not been called, the ToolbarControl is automatically passed as the hook<br />

to the ICommand::OnCreate method.<br />

Hosting the ToolbarMenu directly on the<br />

ToolbarControl<br />

ToolbarMenu<br />

The ToolbarControl can host an item that is a dropdown menu. A<br />

ToolbarMenu item presents a vertical list of single-click command items.<br />

The user must select one of the command items on the ToolbarMenu or<br />

click outside the ToolbarMenu to make it disappear. A ToolbarMenu can<br />

only host command items; no tools or tool controls are permitted. The<br />

ToolbarMenu itself can be hosted on the ToolbarControl, be hosted on<br />

52 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!