0 out of 1 rated this helpful - Rate this topic

Window.HWnd Property

This property supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

int HWnd { get; }
/** @property */
int get_HWnd ()

function get HWnd () : int

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Use of the HWnd property

This property is only available if the Window object you call the HWnd property upon was retrieved through DTE.MainWindow. If DTE.MainWindow.HWnd was used, then this returns the handle to the main window of the application. This property can be used to properly set the parent of any dialog box shown by an Add-in or Macro, and can be used by creating an instance of the following VB Macro code, and passing that instance to the ShowDialog method:

Public Class WinWrapper
    Implements System.Windows.Forms.IWin32Window

    Overridable ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
        Get
            Dim iptr As New System.IntPtr(DTE.MainWindow.HWnd)
            Return iptr
        End Get
    End Property
End Class

 

Unless the Window object was retrieved by calling DTE.MainWindow, the HWnd property will always return the value 0.

Advertisement