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

hr = ipPict->get_Handle(&hBitmap);<br />

if (SUCCEEDED(hr))<br />

m_hBitmap = hBitmap;<br />

}<br />

}<br />

c. In the destructor, you will clean up all the interface member variables.<br />

AddDateTool::AddDateTool()<br />

{<br />

…<br />

}<br />

AddDateTool::~AddDateTool()<br />

{<br />

m_ipHookHelper = 0;<br />

m_hBitmap = 0;<br />

m_hCursor = 0;<br />

}<br />

d. You now need to stub out all the functions from ICommand in<br />

AddDate.cpp, even if you are not going to use some of these. Add the<br />

following code to the ICommand properties and methods:<br />

AddDateTool::~AddDateTool()<br />

{<br />

…<br />

}<br />

HRESULT AddDateTool::get_Enabled(VARIANT_BOOL* Enabled)<br />

{<br />

if (!Enabled)<br />

return E_POINTER;<br />

*Enabled = VARIANT_TRUE;<br />

return S_OK;<br />

}<br />

HRESULT AddDateTool::get_Checked(VARIANT_BOOL* Checked)<br />

{<br />

if (!Checked)<br />

return E_POINTER;<br />

return S_OK;<br />

}<br />

HRESULT AddDateTool::get_Name(BSTR* Name)<br />

{<br />

if (!Name)<br />

return E_POINTER;<br />

*Name = ::AoAllocBSTR(L"CustomCommands_AddDate");<br />

return S_OK;<br />

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

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

Saved successfully!

Ooh no, something went wrong!