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 />

The current tool to<br />

zoom in on the page<br />

A single click<br />

command to<br />

open a map<br />

with the ToolbarControl using the Buddy property. For example, if a command<br />

hosted on the ToolbarControl only works with the ReaderControl and the<br />

ToolbarControl buddy is a MapControl, the command should disable itself.<br />

To help you create custom commands to work with the <strong>ArcGIS</strong> controls and the<br />

<strong>ArcGIS</strong> Desktop applications, HookHelper, GlobeHookHelper, and SceneHookHelper<br />

objects exist.<br />

• The HookHelper is used for custom commands that work with the MapControl,<br />

PageLayoutControl, ToolbarControl, and ArcMap Desktop application.<br />

• The SceneHookHelper is used for custom commands that work with the<br />

SceneControl, ToolbarControl, and ArcScene Desktop application.<br />

• The GlobeHookHelper is used for custom commands that work with the<br />

GlobeControl, ToolbarControl, and ArcGlobe Desktop application.<br />

Rather than requiring you to add code into a command’s OnCreate method to<br />

determine the type of hook passed to the command, the helper object handles<br />

this. The helper objects are used to hold onto the hook and return ActiveView,<br />

PageLayout, Map, Globe, and Scene objects (depending on the type of helper object)<br />

regardless of the type of hook that is passed. Refer to the ‘Building applications’<br />

scenarios in Chapter 6, ‘<strong>Developer</strong> scenarios’, to see how to build a custom<br />

command using the HookHelper object that works with a MapControl,<br />

PageLayoutControl, and ToolbarControl.<br />

The ICommand::OnClick method is called when the end user clicks a command<br />

item hosted on the ToolbarControl. Depending on the type of command, it will<br />

typically do some work using the hook to access the required objects from the<br />

buddy control. There are three types of commands:<br />

• A single-click command implementing the ICommand interface that responds<br />

to a single click. A click results in a call to the ICommand::OnClick method, and<br />

an action is performed. By changing the ICommand::Checked value, simple<br />

command items can behave like a toggle. Single-click commands are the only<br />

types of commands that can be hosted on a menu.<br />

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

that requires end user interaction with<br />

the display of the buddy control. The<br />

A tool control displaying the<br />

current page percentage<br />

A menu<br />

containing<br />

single<br />

click map<br />

commands<br />

ToolbarControl maintains one<br />

CurrentTool. When the end user clicks<br />

the tool on the ToolbarControl, it<br />

becomes the CurrentTool, and the<br />

previous tool is deactivated. The<br />

ToolbarControl will set the CurrentTool<br />

of the buddy control. While the tool<br />

is the CurrentTool, it will receive<br />

mouse and key events from the buddy<br />

control.<br />

Chapter 3 • Developing with <strong>ArcGIS</strong> controls • 51

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

Saved successfully!

Ooh no, something went wrong!