HWND Property (ActiveX)

Gets the window handle of the window frame.

Supported platforms: Windows only

Signature

VBA:

object.HWND
object

Type: Application, Document

The objects this property applies to.

Property Value

Read-only: Yes

Type: Long_PTR

The handle of the window frame.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_HWND()
    ' This example returns the handle (Hwnd) of a document window. The handle can be
    ' used with WindowsAPI calls, or with ActiveX components that require a handle
    ' to a window.
   
    ' If there are no open documents, then exit
    If Documents.Count = 0 Then
        MsgBox "There are no open documents!"
        Exit Sub
    End If
    
    MsgBox "The HWND of the active document is: " & ActiveDocument.HWND
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_HWND()
    ;; This example returns the handle (Hwnd) of a document window. The handle can be
    ;; used with WindowsAPI calls, or with ActiveX components that require a handle
    ;; to a window.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    (alert (strcat "The HWND of the active document is: " (itoa (vla-get-HWND doc))))
)