This document is archived and information here might be outdated.  Recommended version.


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

.NET Samples

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

.NET Related Topics

Adding a custom menu created in .NET to ArcGIS for 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