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

8. Update the makefile. Include PageLayoutControlEvents.cpp as a source, add<br />

the header for the events to the MapViewer.o dependencies list, and add a<br />

dependencies list for PageLayoutControlEvents.o.<br />

9. Compile and run the application. The map document is now loaded into the<br />

PageLayoutControl; and the TOCControl lists the data layers in the<br />

MapDocument. By default, the focus map of the map document is loaded into<br />

the MapControl.<br />

Setting the Buddy Control for the TOCControl and ToolbarControl<br />

For the purpose of this application, the TOCControl and ToolbarControl will<br />

work in conjunction with the PageLayoutControl rather than the MapControl. To<br />

do this the PageLayoutControl must be set as the buddy control. The<br />

TOCControl uses the buddy’s ActiveView to populate itself with maps, layers,<br />

and symbols, while any command, tool, or menu items present on the<br />

ToolbarControl will interact with the buddy control’s display.<br />

1. The buddy control is set after the widgets are created and their interface<br />

pointers have been assigned, so you will set each one after FormSetup().<br />

FormSetup(argc, argv, &app_context);<br />

// Buddy the toolbar and TOC with the PageLayoutControl<br />

g_ipToolbarControl->SetBuddyControl(g_ipPageLayoutControl);<br />

g_ipTOCControl->SetBuddyControl(g_ipPageLayoutControl);<br />

374 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong><br />

// Event listening<br />

2. Remake the application and run it again. Notice that now the TOCControl<br />

displays a layer icon as well as the data for the current document. Use the<br />

TOCControl to toggle layer visibility by checking and unchecking the boxes.<br />

At this point the ToolbarControl is empty because no commands have been<br />

added to it.

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

Saved successfully!

Ooh no, something went wrong!