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 C++ AND CONTROL WIDGETS<br />

1. In your text editor, start a new file, AddDate.h.<br />

2. In AddData.h, create a new class, AddDateTool, which inherits from<br />

CAoToolBase. Include a public constructor and destructor.<br />

#ifndef __ADD_DATE_H_<br />

#define __ADD_DATE_H_<br />

Since the non-GUI-specific Ao/AoControls.h and<br />

Ao/AoToolBase.h are used, the custom tool, like<br />

the custom events, will work with both GTK and<br />

Motif applications.<br />

// ArcObjects Headers<br />

// <strong>Engine</strong><br />

#include <br />

// Controls<br />

#include <br />

// Custom Tool<br />

#include <br />

class AddDateTool : public CAoToolBase<br />

{<br />

public:<br />

AddDateTool();<br />

~AddDateTool();<br />

};<br />

#endif<br />

// #define __ADD_DATE_H_<br />

3. Since you are writing a new tool, it must implement both ICommand and ITool,<br />

both defined in CAoToolBase. In AddDate.h you place the declarations for the<br />

functions supported by ICommand and ITool. For this command to work with<br />

all the different controls, you will use the IHookHelper interface, storing the<br />

hook in a private member variable, m_ipHookHelper. You will also provide<br />

member variables for the tool’s icon and bitmap.<br />

class AddDateTool : public CAoToolBase<br />

{<br />

public:<br />

AddDateTool();<br />

~AddDateTool();<br />

// ICommand<br />

HRESULT get_Enabled(VARIANT_BOOL* Enabled);<br />

HRESULT get_Checked(VARIANT_BOOL* Checked) ;<br />

HRESULT get_Name(BSTR* Name);<br />

HRESULT get_Caption(BSTR* Caption);<br />

HRESULT get_Tooltip(BSTR* Tooltip);<br />

HRESULT get_Message(BSTR* Message);<br />

HRESULT get_Bitmap(OLE_HANDLE* bitmapFile);<br />

HRESULT get_Category(BSTR* categoryName);<br />

HRESULT OnCreate(IDispatch* hook);<br />

HRESULT OnClick();<br />

// ITool<br />

HRESULT get_Cursor(OLE_HANDLE* cursorName);<br />

HRESULT OnMouseDown(LONG Button, LONG Shift, LONG X, LONG Y);<br />

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

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

Saved successfully!

Ooh no, something went wrong!