Purpose
This sample demonstrates how to set the PageLayout control's FocusMap and use the IObjecyCopy object to overwrite the Map control's Map object with a copy of the PageLayout control's FocusMap. The Map object must be copied because the Map control and PageLayout control cannot share the same active view.
The browse dialog allows you to search and select map documents, which are then validated and loaded into the PageLayout control using the CheckMxFile and LoadMxFile methods. This triggers the OnPageLayoutReplaced event, which loops through the elements in the PageLayout control's graphics container, finding MapFrame elements. The name of each MapFrame is set to the name of the map in the MapFrame using the IElementProperties interface. A combo box is populated with all the map names to allow you to change the FocusMap. The FindElementByName method is used to find the MapFrame containing the map that will become the FocusMap.
The PageLayout control's OnFocusMapChanged and OnAfterScreenDraw events (when a new map document has been loaded into the PageLayout control) use the IObjectCopy Copy and Overwrite methods to overwrite the Map control's map with a copy of the PageLayout control's FocusMap.
The PageLayout control and Map control OnMouseDown events use the TrackRectangle and Pan methods to zoom in and pan either the PageLayout control's page or the Map control's map. If the Map control display is redrawn due to a change in visible extent, the OnAfterScreenDraw event is used to set the extent of the PageLayout control's FocusMap equal to that of the Map control using the IDisplayTransformation interface.
How to use
See
How to use ArcGIS samples for help on running the sample.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders.
However, you will need to update the sample to point to the location of the data once you have extracted all the files.
Run the sample.
Load a map document into the PageLayout control.
Use the left mouse button to zoom in and the right mouse button to pan both page and map data.
Change the PageLayout control's FocusMap.
Download the files for Java
pagelayoutbean/CopyFocusMap.java
Main class
Development licensing
Deployment licensing
Engine Developer Kit
Engine Runtime
ArcView
ArcEditor
ArcInfo