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

d. Remember to clean up the global variables when the application closes.<br />

// Function called when WM_DELETE_WINDOW protocol is passed<br />

void CloseAppCallback(Widget w, XtPointer client_data, XtPointer<br />

call_data)<br />

{<br />

…<br />

delete g_tocEvents;<br />

g_ipPopupMenu = 0;<br />

g_ipFillSymbol = 0;<br />

g_ipCurrentExtent = 0;<br />

g_ipToolbarControl = 0;<br />

3. To have the MapControl work as an overview window, it must display the full<br />

extent of the data. Since this needs to be done every time there is a new map<br />

document, the following code should be placed into the<br />

PageLayoutControlEvents.cpp file’s OnPageLayoutReplaced event.<br />

void PageLayoutControlEvents::OnPageLayoutReplaced(VARIANT newPageLayout)<br />

{<br />

// Load the same pre-authored map document into the MapControl<br />

CComBSTR DocFileName;<br />

IPageLayoutControl2Ptr ipPage2 = g_ipPageLayoutControl;<br />

ipPage2->get_DocumentFilename(&DocFileName);<br />

g_ipMapControl->LoadMxFile(DocFileName);<br />

// Set the extent of the MapControl to be the full extent<br />

IEnvelopePtr ipFullExtentEnv;<br />

g_ipMapControl->get_FullExtent(&ipFullExtentEnv);<br />

g_ipMapControl->put_Extent(ipFullExtentEnv);<br />

}<br />

4. The global variable g_ipCurrentExtent, which will be used to draw the overview<br />

on the MapControl, needs to be updated with every new PageLayout. To<br />

implement this, you will need access to the g_ipCurrentExtent global variable<br />

from within the PageLayoutControlEvents class. Add the following into<br />

PageLayoutControlEvents.h:<br />

extern IToolbarMenuPtr g_ipPopupMenu;<br />

extern IEnvelopePtr g_ipCurrentExtent;<br />

5. To update the extent rectangle on the overview map to match the extent<br />

shown in every new PageLayout, you need to set the current extent rectangle to<br />

match the visible extent of the PageLayout’s map. Do this in the<br />

OnPageLayoutReplaced event (in PageLayoutControlEvents.cpp).<br />

void PageLayoutControlEvents::OnPageLayoutReplaced(VARIANT newPageLayout)<br />

{<br />

// Get the extent of the PageLayout's focus map<br />

IActiveViewPtr ipActiveView;<br />

g_ipPageLayoutControl->get_ActiveView(&ipActiveView);<br />

IMapPtr ipFocusMap;<br />

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