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

The ICommand_OnCreate event is passed a<br />

handle or hook to the application that the<br />

command will work with. In this case it can be a<br />

MapControl, PageLayoutControl, or<br />

ToolbarControl. Rather than adding code into<br />

the OnCreate event to determine the type of<br />

hook that is being passed to the command, you<br />

will use the HookHelper to handle this. A<br />

command or tool needs to know how to handle<br />

the hook it gets passed, so a check is needed to<br />

determine the type of <strong>ArcGIS</strong> Control that has<br />

been passed. The HookHelper is used to hold the<br />

hook and return the ActiveView regardless of the<br />

type of hook (in this case a MapControl,<br />

PageLayoutControl, or ToolbarControl).<br />

Private Property Get ICommand_Tooltip() As String<br />

ICommand_Tooltip = "Add date"<br />

End Property<br />

10. You now need to stub out all of the properties and events of the ITool interface,<br />

even if you are not going to use some of these. Add the following code<br />

to the ITool properties and methods:<br />

Private Property Get ITool_Cursor() As esriSystem.OLE_HANDLE<br />

' Not implemented<br />

End Property<br />

Private Function ITool_Deactivate() As Boolean<br />

ITool_Deactivate = True<br />

End Function<br />

Private Function ITool_OnContextMenu(ByVal x As Long, ByVal y As Long) As<br />

Boolean<br />

' Not implemented<br />

End Function<br />

Private Sub ITool_OnDblClick()<br />

' Not implemented<br />

End Sub<br />

Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal shift As Long)<br />

' Not implemented<br />

End Sub<br />

Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal shift As Long)<br />

' Not implemented<br />

End Sub<br />

Private Sub ITool_OnMouseDown(ByVal button As Long, ByVal shift As Long,<br />

ByVal x As Long, ByVal y As Long)<br />

' Get the active view.<br />

Dim pActiveView As IActiveView<br />

Set pActiveView = m_pHookHelper.ActiveView<br />

' Create a new text element.<br />

Dim pTextElement As ITextElement<br />

Set pTextElement = New TextElement<br />

' Create a text symbol.<br />

Dim pTextSymbol As ITextSymbol<br />

Set pTextSymbol = New TextSymbol<br />

' Create a font.<br />

Dim pFont As stdole.StdFont<br />

Set pFont = New stdole.StdFont<br />

pFont.Name = "Arial"<br />

pFont.Bold = True<br />

pFont.Size = 25<br />

Chapter 6 • <strong>Developer</strong> scenarios • 297

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

Saved successfully!

Ooh no, something went wrong!