18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH ACTIVEX<br />

Loading map documents into the PageLayoutControl and<br />

MapControl<br />

Individual data layers or preauthored ESRI map documents can be loaded into<br />

the MapControl and PageLayoutControl. You can either load the sample map<br />

document provided or you can load your own map document. Later you will add<br />

a dialog box to browse to a map document.<br />

1. Double-click the form to display the code window.<br />

2. Click the Form_Load event and enter the following code. (If you are using<br />

your own map document, substitute the filename.)<br />

Private Sub Form_Load()<br />

' Check and load a preauthored map document into the PageLayoutControl<br />

using relative paths.<br />

Dim sFileName As String<br />

sFileName = "..\..\..\..\..\..\Data\<strong>ArcGIS</strong>_<strong>Engine</strong>_<strong>Developer</strong>_<strong>Guide</strong>\Gulf<br />

of St. Lawrence.mxd"<br />

If PageLayoutControl1.CheckMxFile(sFileName) Then<br />

PageLayoutControl1.LoadMxFile sFileName<br />

End If<br />

End Sub<br />

3. Click the PageLayoutControl_ OnPageLayoutReplaced event and enter the<br />

following code to load the same map document into the MapControl. The<br />

OnPageLayoutReplaced event will be triggered whenever a document is<br />

loaded into the PageLayoutControl.<br />

Private Sub PageLayoutControl1_OnPageLayoutReplaced(ByVal newPageLayout<br />

As Variant)<br />

' Load the same preauthored map document into the MapControl.<br />

MapControl1.LoadMxFile PageLayoutControl1.DocumentFilename<br />

' Set the extent of the MapControl to the full extent of the data.<br />

MapControl1.Extent = MapControl1.FullExtent<br />

End Sub<br />

Setting the TOCControl and ToolbarControl buddy controls<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. Double-click the form to display the code window.<br />

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