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


Get hWnd from ArcGIS Desktop Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Get hWnd from ArcGIS Desktop Snippet

Gets the Windows Handle (hWnd) of the ArcGIS Desktop application that is currently running. If you need a Windows Handle for a custom application use System.Runtime.InteropServices.Marshal.GetHINSTANCE instead.

[C#]
///<summary>Gets the Windows Handle (hWnd) of the ArcGIS Desktop application that is currently running. If you need a Windows Handle for a custom application use System.Runtime.InteropServices.Marshal.GetHINSTANCE instead.</summary>
/// 
///<param name="application">An IApplication interface.</param>
/// 
///<returns>A System.Int32 that is the Windows handle.</returns>
/// 
///<remarks></remarks>
public System.Int32 GetHWndFromArcGISDesktop(ESRI.ArcGIS.Framework.IApplication application)
{
  System.Int32 hWnd=application.hWnd;

  return  hWnd;
}
[Visual Basic .NET]
'''<summary>Gets the Windows Handle (hWnd) of the ArcGIS Desktop application that is currently running. If you need a Windows Handle for a custom application use System.Runtime.InteropServices.Marshal.GetHINSTANCE instead.</summary>
''' 
'''<param name="application">An IApplication interface.</param>
''' 
'''<returns>A System.Int32 that is the Windows handle.</returns>
''' 
'''<remarks></remarks>
Public Function GetHWndFromArcGISDesktop(ByVal application As ESRI.ArcGIS.Framework.IApplication) As System.Int32

  Dim hWnd As System.Int32=application.hWnd

  Return hWnd

End Function

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