Link to home
Start Free TrialLog in
Avatar of bmatumbura
bmatumbura

asked on

Get the Min/Max State of a window

I need a VB boolean function that takes a handle to a window (hWnd as Long) as a parameter. The function then checks the Min/Max status of the Window. It must return True if the Window is Minimized, False otherwise.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The use isZoom API to determine whether a window is maximized.
Declare Function IsZoomed Lib "user32" Alias "IsZoomed" (ByVal hwnd As Long) As Long

Example:

Private Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form_Activate()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Me.AutoRedraw = True
    Me.Print "Was the window maximized onstartup? " + Str$(CBool(IsZoomed(Me.hwnd)))
    Me.WindowState = vbMaximized
    Me.Print "Is the window now maximized? " + Str$(CBool(IsZoomed(Me.hwnd)))
End Sub

cheers