Get MxApplication from ArcMap.
[C#]
///<summary>Get MxApplication from ArcMap</summary> ///<param name="application">An IApplication interface that is the ArcMap application.</param> ///<returns>An IMxApplication interface.</returns> ///<remarks>The IMxApplication interface allows access the AppDisplay object, the selection environment, and the default printer page settings.</remarks> public ESRI.ArcGIS.Carto.IMap GetMxApplicationFromArcMap(ESRI.ArcGIS.Framework.IApplication application) { if (application == null) { return null; } if (! (application is ESRI.ArcGIS.ArcMapUI.IMxApplication)) { return null; } ESRI.ArcGIS.ArcMapUI.IMxApplication mxApplication = (ESRI.ArcGIS.ArcMapUI.IMxApplication)application; // Explicit Cast return (ESRI.ArcGIS.Carto.IMap)mxApplication; }
[Visual Basic .NET]
'''<summary>Get MxApplication from ArcMap</summary> '''<param name="application">An IApplication interface that is the ArcMap application.</param> '''<returns>An IMxApplication interface.</returns> '''<remarks>The IMxApplication interface allows access the AppDisplay object, the selection environment, and the default printer page settings.</remarks> Public Function GetMxApplicationFromArcMap(ByVal application As ESRI.ArcGIS.Framework.IApplication) As ESRI.ArcGIS.Carto.IMap If application Is Nothing Then Return Nothing End If If Not TypeOf application Is ESRI.ArcGIS.ArcMapUI.IMxApplication Then Return Nothing End If Dim mxApplication As ESRI.ArcGIS.ArcMapUI.IMxApplication = CType(application, ESRI.ArcGIS.ArcMapUI.IMxApplication) ' Explicit Cast Return CType(mxApplication, ESRI.ArcGIS.Carto.IMap) End Function