ArcObjects Library Reference (Carto)  

IActiveView Interface

Provides access to members that control the active view - the main application window.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

When To Use

This interface manages the main application window in ArcMap and all drawing operations.

In ArcMap, two objects implement this interface: PageLayout and Map.  These two objects correspond to the two different views in ArcMap: layout and data view. Only one view can be active at a time and this is termed the active view. IMxDocument::ActiveView holds a reference to the current active view object (a Map or the PageLayout). For example, if the ArcMap application is in layout mode, IMxDocument::ActiveView returns an IActiveView reference to the PageLayout object.  Alternatively, if the application is in data view, this propery returns a reference to the focus map. 

ArcMap has view commands which allow users to toggle between layout view and data view. These commands appear on the View menu and on the scroll bar.

An ArcMap document can contain many Maps. Make sure you have the desired object when working with this interface. Otherwise, operations such as drawing may not be occurring in the application window as you expect. For example, a Map obtained through IMxDocument::Maps is not guaranteed to be the focus map. If you know you want a reference to the focus map, use IMxDocument::FocusMap.  Similarly, if you know you want a reference to the page layout, use IMxDocument::PageLayout instead. You can change the document's active view by setting IMxDocument::ActiveView. Learn more by reading the help for this property. 



 

Members

Description
Method Activate Gives this view control of the specified window.
Method Clear Empties the view contents.
Method ContentsChanged Called by clients when view objects are modified.
Method Deactivate Another view takes over the associated window.
Method Draw Draws the view to the specified device context.
Read-only property ExportFrame The device rectangle to export.
Read/write property Extent The visible extent rectangle.
Read-only property ExtentStack The extent stack.
Read/write property FocusMap The map that tools and controls act on.
Read/write property FullExtent The full extent rectangle.
Method GetContextMenu Called when a context menu should be displayed at the given xy location. Return menu that should be displayed.
Read-only property GraphicsContainer The active graphics container.
Method HitTestMap Returns any maps present in the view at the given location. Return value may be zero if there are no maps or the coordinate is not over a map.
Method IsActive Indicates if view is active or not.
Read/write property IsMapActivated Indicates if the focus map is activated.
Method OnMessage Call from your application's message loop to enable automatic resizing and keyboard accelerators.
Method Output Renders the view to the specified DC.
Method PartialRefresh Draws the specified view phase. Use an envelope of zero to draw the entire phase.
Method PrinterChanged Called by application when printer changes.
Method Refresh Causes the entire view to draw.
Read-only property ScreenCacheID The screen cache ID that is used to draw the specified phase.
Read-only property ScreenDisplay The screen display used by the view.
Read/write property Selection The selection.
Read/write property ShowRulers Indicates if rulers are visible.
Read/write property ShowScrollBars Indicates if scrollbars are visible.
Read/write property ShowSelection Indicates if selection is visible.
Read-only property TipText The tip text to display at the given location.

CoClasses that implement IActiveView

CoClasses and Classes Description
Globe (esriGlobeCore) A container for the display and manipulation of data in the Globe.
Map A container for the display and manipulation of map data.
PageLayout Page Layout class contains maps and map surrounds.
Scene (esri3DAnalyst) A container for the display and manipulation of data.

Remarks

When working with the IActiveView interface on a MapDocument object, you should always first call IActiveView::Activate() in order to properly initialize the display of the PageLayout or Map object. The MxDocument and MapServer objects initialize display objects automatically after opening an MXD, but MapDocument does not do this.   If your application has a user interface, you should call Activate() with the hWnd of the application's client area.  If your application runs in the background and has no windows, you can always get a valid hWnd from the GDI GetDesktopWindow() function, part of the Win32 API.

 

See Also

IMxDocument.ActiveView Property

.NET Snippets

Get MxApplication from ArcMap | Set Max Extent On Spatial Domain | Draw Polygon | Create JPEG (hi-resolution) from ActiveView | Create Spatial Bookmark for ActiveView Extent | Get All Features from Point Search in GeoFeatureLayer | Add North Arrow | Add Scale Bar | Draw Rectangle | Draw Polyline | Convert Display Pixels to Map Units | Clear NAClass | Add Hyperlink | Add Layer File to ActiveView | Toggle Visibility Of Composite Layer | Get Polyline From Mouse Clicks | Get Map from ArcMap | Clear Active Analysis Layer | Add Event Wiring for All IActiveViewEvents | Zoom by Ratio | Get FeatureLayer from Layer Index Number | Do Identify | Zoom to Layer by Index Number | Delete Graphics Refresh ActiveView | Get Screen Coordinates from Map Coordinates | Create JPEG from ActiveView | Clear Selected Map Features | Get ActiveView from ArcMap | Get Map Coordinates from Screen Coordinates | Get GeoFeatureLayer from Layer Index Number | Add Shapefile Using OpenFileDialog | Zoom by Ratio and Recenter | Draw Point | Draw Polyline Using Input Geometry | Zoom to Active Layer in TOC | Create Graphic Buffers around Selected Features | Get Index Number from Layer Name | Select Map Features by Attribute Query | Get First Feature from Point Search in GeoFeatureLayer |

.NET Samples

Add a custom bookmarks MultiItem to the ToolbarControl (Code Files: CreateBookmark) | Add a custom menu created in .NET to ArcGIS Desktop (Code Files: AddShapefile) | Applying a time offset to a time-aware feature layer (Code Files: TimeOffsetButton) | Building a MapViewer application using the ArcGIS Engine controls (Code Files: AddDateTool MapViewer) | Configure a command for a specific locale (Code Files: CultureTool) | Convert part to feature command (Code Files: ConvertPart) | Copy the PageLayoutControl focus map and overwrite the MapControl map (Code Files: CopyFocusMap) | Create a command by inheriting from BaseCommand (Code Files: ZoomToLayer) | Create a custom selection extension by extending ArcObjects (Code Files: SelectByLineTool) | Create a custom tool (Code Files: DrawGraphicLine) | Creating a zoom factor extension that works with a ToolbarControl (Code Files: ZoomIn ZoomOut) | Custom map navigation commands (Code Files: FixedZoomIn FixedZoomOut FullExtent GoBackToPreviousExtent GoToNextExtent Pan PanDown PanLeft PanRight PanUp ZoomIn ZoomOut) | Custom map selection commands (Code Files: ClearFeatureSelection SelectFeatures) | Custom reshape polyline edit task (Code Files: ReshapePolylineEditTask) | Custom selection extension (Code Files: SelectByLineTool) | Custom UI elements using add-ins (Code Files: AddGraphicsTool ZoomToLayerButton) | Cut polygons without selection edit task (Code Files: CutPolygonsWithoutSelectionEditTask) | Dynamic biking (Code Files: DynamicBikingCmd) | Dynamic display animated zoom (Code Files: AnimatedZoomInTool AnimatedZoomOutTool) | Dynamic logo (Code Files: DynamicLogo) | Export active view (Code Files: ExportActiveViewVB_Net) | Geodesy MapControl (Code Files: GeodesyMapControl) | Implementing a schematic digitizing tool (Code Files: DigitTool) | Layer effects animation in ArcMap (Code Files: AnimationTypeLayerEffects) | Layer property page and property sheet (Code Files: LayerVisibilityPage) | Make a custom time slider (Code Files: CustomTimeSliderButton) | Move a graphic along a path in ArcMap (Code Files: AnimationTypeMapGraphic MapGraphicKeyframe) | Print active view (Code Files: PrintActiveViewVB_Net_Addin) | Print active view with ArcPress (Code Files: PrintActiveViewArcPressVB_Net_Addin) | Print multiple pages (Code Files: PrintMultiPagesVB_NET_Addin) | RSS weather layer (Code Files: AddRSSWeatherLayer AddWeatherItemTool WeatherItemSelectionDlg) | Schematic diagram auto refresh (Code Files: FormAutorefresh) | Set flow by digitized direction (Code Files: SetFlowByDigitizedDirectionVBNet) | Set the time extents for a layer then render the layer (Code Files: SetTimeExtentsButton) | StreetMap routing (Code Files: RoutingForm) | Use an AlgorithmicColorRamp to color a ClassBreaksRenderer (Code Files: AlgorithmicColorRamp) | Using MOLE symbol-based graphics with interactive maps (Code Files: MainForm) | Using the traversal result to select source features (Code Files: SelectFeaturesTool) |

.NET Related Topics

Adding a custom menu created in .NET to ArcGIS Desktop | Building a map viewing application using the ArcGIS Engine controls | Building custom UI elements using add-ins | CatalogUI | Converting labels to geodatabase annotation for a single layer | Converting labels to geodatabase annotation for an entire map | Converting labels to map annotation for a single layer | Create a command by inheriting from BaseCommand | Create a custom tool | Creating and working with basemap layers | Display events | How to add display caching | How to create a raster catalog layer | How to create a raster layer | How to create AOIs and bookmarks | How to create dynamic menu commands using a MultiItem | How to create map grids | How to draw a point on the screen | How to draw a polygon on the screen | How to draw a polyline on the screen | How to draw a rectangle on the screen | How to get map coordinates from screen coordinates | How to get screen coordinates from map coordinates | How to set output image quality | How to wire custom events using IActiveViewEvents | Performing basic map functions | Performing map selection | Publisher | Selection trackers | Working with map elements | Working with map surrounds | Working with PageLayout elements | Working with the edit sketch |