Copy focus map

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 box 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 becomes 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 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.

  1. Run the sample.
  2. Load a map document into the PageLayout control.
  3. Use the left mouse button to zoom in and the right mouse button to pan both page and map data.
  4. Change the PageLayout control's FocusMap.

If you installed the samples feature, you will find the files associated with this sample in <Your Developer Kit install location>\DeveloperKit10.4\Java\Samples\ArcObjects.

pagelayoutbean/ Main class.

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced