18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH C++ AND CONTROL WIDGETS<br />

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

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

HRESULT OnDblClick();<br />

HRESULT OnKeyDown(LONG keyCode, LONG Shift);<br />

HRESULT OnKeyUp(LONG keyCode, LONG Shift);<br />

HRESULT OnContextMenu(LONG X, LONG Y, VARIANT_BOOL* handled);<br />

HRESULT Refresh(OLE_HANDLE ole);<br />

HRESULT Deactivate(VARIANT_BOOL* complete);<br />

private:<br />

IHookHelperPtr m_ipHookHelper;<br />

OLE_HANDLE m_hBitmap;<br />

OLE_HANDLE m_hCursor;<br />

};<br />

#endif // #define FULLEXTENT_H_<br />

4. Open a new file in your text editor, and name it AddDate.cpp. Here you will<br />

implement your custom tool.<br />

a. Include AddDate.h.<br />

#include "AddDate.h"<br />

b. In the constructor, you will load the bitmap and cursor, as well as create the<br />

IHookHelper. If you want to use the provided icon and mouse cursor, copy<br />

the resources from arcgis/developerkit/samples/<br />

<strong>Developer</strong>_<strong>Guide</strong>_Scenarios/<strong>ArcGIS</strong>_<strong>Engine</strong>/<br />

Building_an_<strong>ArcGIS</strong>_Control_Application/Map_Viewer/Res/ to your<br />

code directory.<br />

#include "AddDate.h"<br />

AddDateTool::AddDateTool()<br />

{<br />

m_ipHookHelper.CreateInstance(CLSID_HookHelper);<br />

// Load the cursor<br />

ISystemMouseCursorPtr ipSysMouseCur(CLSID_SystemMouseCursor);<br />

ipSysMouseCur->LoadFromFile(CComBSTR(L"../Res/date.cur"));<br />

OLE_HANDLE hTmp;<br />

HRESULT hr = ipSysMouseCur->get_Cursor(&hTmp);<br />

if (SUCCEEDED(hr))<br />

{<br />

m_hCursor = hTmp;<br />

}<br />

// Load the bitmap<br />

IRasterPicturePtr ipRastPict(CLSID_BasicRasterPicture);<br />

IPicturePtr ipPict;<br />

hr = ipRastPict->LoadPicture(CComBSTR(L"../Res/date.bmp"), &ipPict);<br />

if (SUCCEEDED(hr))<br />

{<br />

OLE_HANDLE hBitmap;<br />

394 • <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!