ArcObjects Library Reference  (Carto)    

IActiveView IsMapActivated Example

Public Sub AddDataFrame()
 
  Dim pContentsView As IContentsView
  Dim pApp As IMxApplication
  Dim pMap As IMap
  Dim pMaps As IMaps
  Dim pMxDocument As IMxDocument
  Dim pActiveView As IActiveView
 
  Set pApp = Application
  Set pMxDocument = ThisDocument
  Set pActiveView = pMxDocument.ActiveView
  Set pMaps = pMxDocument.Maps
  Set pMap = pMaps.Create
 
  pMaps.Add pMap
 
  Set pContentsView = pMxDocument.CurrentContentsView
  pContentsView.Refresh pMxDocument
 
  Dim pMapFrame As IMapFrame
  Dim pMapExt As IEnvelope
 
  Set pMapFrame = New MapFrame
  Set pMapExt = New Envelope
  Set pMapFrame.Map = pMap
 
  pMapExt.XMin = 3
  pMapExt.YMin = 3
  pMapExt.XMax = 7
  pMapExt.YMax = 7
 
  Dim pMapElement As IElement
  Dim pGeoExt As IGeometry
 
  Set pMapElement = pMapFrame
  Set pGeoExt = pMapExt
  pMapElement.Geometry = pGeoExt
 
  If pActiveView.IsMapActivated Then
    Set pMxDocument.ActiveView = pMap
    Dim pGraphicsContainer As IGraphicsContainer
    Set pGraphicsContainer = pMxDocument.PageLayout
    pGraphicsContainer.AddElement pMapElement, 2
  Else
    pActiveView.GraphicsContainer.AddElement pMapElement, 2
    pMapElement.Activate pApp.Display
  End If
  pActiveView.Refresh
 
End Sub


[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.