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

Drawing an overview rectangle on the MapControl<br />

You will now use the MapControl as an overview window and draw the current<br />

extent of the focus map within the PageLayoutControl on its display. As you<br />

navigate around the data within the data frame of the PageLayoutControl, you<br />

will see the MapControl overview window update.<br />

Navigating around the focus map using the map<br />

navigation tools will change the extent of the<br />

focus map in the PageLayoutControl and cause<br />

the MapControl to update. Navigating around<br />

the page layout with the page layout navigation<br />

tools will change the extent of the page layout<br />

(not the extent of the focus map in the<br />

PageLayoutControl), so the MapControl will<br />

not update.<br />

1. First add IFillSymbol and IEnvelope interface pointers to the top of<br />

MapViewer.cpp.<br />

IToolbarMenuPtr g_ipPopupMenu;<br />

IFillSymbolPtr g_ipFillSymbol;<br />

IEnvelopePtr g_ipCurrentExtent;<br />

int main(int argc, char* argv[])<br />

2. You will use a new function to create the rectangle used on the MapControl to<br />

highlight the current PageLayoutControl extent.<br />

a. First place the forward declaration in MapViewer.h.<br />

void AddPopupItems();<br />

HRESULT CreateOverviewSymbol();<br />

b. Place the implementation of that function at the end of MapViewer.cpp.<br />

void AddPopupItems()<br />

{<br />

…<br />

}<br />

HRESULT CreateOverviewSymbol()<br />

{<br />

// IRgbColor interface<br />

IRgbColorPtr ipColor(CLSID_RgbColor);<br />

ipColor->put_Red(255);<br />

ipColor->put_Green(0);<br />

ipColor->put_Blue(0);<br />

Alternatively, symbols can be retrieved from style<br />

galleries. When working with style galleries and<br />

the C++ API, ServerStyleGallery should be used<br />

as it is across platforms.<br />

// ILine symbol interface<br />

ILineSymbolPtr ipOutline(CLSID_SimpleLineSymbol);<br />

ipOutline->put_Width(2);<br />

ipOutline->put_Color(ipColor);<br />

// IFillSymbol properties<br />

g_ipFillSymbol.CreateInstance(CLSID_SimpleFillSymbol);<br />

g_ipFillSymbol->put_Outline(ipOutline);<br />

((ISimpleFillSymbolPtr) g_ipFillSymbol)->put_Style(esriSFSHollow);<br />

return S_OK;<br />

}<br />

c. Create the symbol in the main function of MapViewer.cpp before the<br />

TOCControl label editing code.<br />

CreateOverviewSymbol();<br />

g_ipTOCControl->put_LabelEdit(esriTOCControlManual);<br />

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

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

Saved successfully!

Ooh no, something went wrong!