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


Move Application Window to Center Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Move Application Window to Center Snippet

Move application back to center if not completely visible on screen.

[C#]
///<summary>Move application back to center if not completely visible on screen.</summary>
///  
///<param name="application">An IApplication interface.</param>
///   
/// <remarks></remarks>
public void MoveApplicationWindowToCenter(ESRI.ArcGIS.Framework.IApplication application)
{
  ESRI.ArcGIS.Framework.IWindowPosition windowPos=application as ESRI.ArcGIS.Framework.IWindowPosition;
  if (windowPos.State == ESRI.ArcGIS.Framework.esriWindowState.esriWSNormal)
  {
    windowPos.Left=10;
    windowPos.Top=10;
  }
}
[Visual Basic .NET]
'''<summary>Move application back to center if not completely visible on screen.</summary>
'''  
'''<param name="application">An IApplication interface.</param>
'''   
''' <remarks></remarks>
Public Sub MoveApplicationWindowToCenter(ByVal application As ESRI.ArcGIS.Framework.IApplication)

  Dim windowPos As ESRI.ArcGIS.Framework.IWindowPosition=CType(application, ESRI.ArcGIS.Framework.IWindowPosition)

  If windowPos.State=ESRI.ArcGIS.Framework.esriWindowState.esriWSNormal Then

    windowPos.Left=10
    windowPos.Top=10

  End If

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Framework
  • ESRI.ArcGIS.System