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

// End event listening<br />

g_ipPageLayoutControlEventHelper->UnadviseEvents();<br />

g_ipPageLayoutControlEventHelper->Shutdown();<br />

g_ipPageLayoutControlEventHelper = 0;<br />

delete g_pageLayoutEvents;<br />

g_ipPopupMenu = 0;<br />

Note that only tools and commands that are<br />

registered on the system as COM components<br />

can be added to the popup menu using the<br />

AddItem method. Custom C++ commands and<br />

tools, like the one you will build later, cannot be<br />

added to the popup menu, as they are not<br />

registered as COM components in the system<br />

registry.<br />

g_ipToolbarControl = 0;<br />

4. Place some commands on the popup menu. This is done in the AddPopupItems<br />

function.<br />

a. Again, start with a forward declaration in the header file, MapViewer.h:<br />

void AddToolbarItems();<br />

void AddPopupItems();<br />

b. Implement the function at the bottom of MapViewer.cpp.<br />

void AddToolbarItems()<br />

{<br />

…<br />

}<br />

void AddPopupItems()<br />

{<br />

CComVariant varTool;<br />

long popupItemIndex;<br />

varTool = L"esriControlCommands.ControlsPageZoomInFixedCommand";<br />

g_ipPopupMenu->AddItem(varTool, 0, -1, VARIANT_FALSE,<br />

esriCommandStyleIconAndText, &popupItemIndex);<br />

varTool = L"esriControlCommands.ControlsPageZoomOutFixedCommand";<br />

g_ipPopupMenu->AddItem(varTool, 0, -1, VARIANT_FALSE,<br />

esriCommandStyleIconAndText, &popupItemIndex);<br />

varTool = L"esriControlCommands.ControlsPageZoomWholePageCommand";<br />

g_ipPopupMenu->AddItem(varTool, 0, -1, VARIANT_FALSE,<br />

esriCommandStyleIconAndText, &popupItemIndex);<br />

varTool =<br />

L"esriControlCommands.ControlsPageZoomPageToLastExtentBackCommand";<br />

g_ipPopupMenu->AddItem(varTool, 0, -1, VARIANT_TRUE,<br />

esriCommandStyleIconAndText, &popupItemIndex);<br />

varTool =<br />

L"esriControlCommands.ControlsPageZoomPageToLastExtentForwardCommand";<br />

g_ipPopupMenu->AddItem(varTool, 0, -1, VARIANT_FALSE,<br />

esriCommandStyleIconAndText, &popupItemIndex);<br />

}<br />

c. Add commands to the popup menu by calling the function just written.<br />

g_ipPopupMenu->SetHook(g_ipPageControl);<br />

AddPopupItems();<br />

AddToolbarItems();<br />

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