hWnd Property Example

The following example uses the hWnd property with the Windows API IsZoomed function to determine if a window is maximized.

' Enter on single line in Declarations section of Module window.
Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long

Sub Form_Activate()
    Dim intWindowHandle As Long
    intWindowHandle = Screen.ActiveForm.hWnd
    If Not IsZoomed(intWindowHandle) Then
        DoCmd.Maximize
    End If
End Sub