Check if a window is minimized
Posted: Tue Oct 09, 2001 11:12 pm
Code updated for 5.20+ (same as GetWindowState())
Restored from previous forum. Originally posted by Franco.
Have a nice day...
Franco
Restored from previous forum. Originally posted by Franco.
Code: Select all
; (c) 2001 - Franco's template - absolutely freeware
; IsIconic checks if a window is minimized or not.
; So if to store the window size and position is needed
; you can prevent to save minimized values when you close
; a minimized window.
Procedure _ScreenWidth ()
ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN)
EndProcedure
Procedure _ScreenHeight ()
ProcedureReturn GetSystemMetrics_ (#SM_CYSCREEN)
EndProcedure
; draw a window and place it outside the desktop
If OpenWindow(0, _ScreenWidth (), _ScreenHeight (), 320, 240, "Test if Window is minimized or not", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
xPos = (_ScreenWidth () / 2) - (WindowWidth(0) / 2)
yPos = (_ScreenHeight () / 2) - (WindowHeight(0) / 2)
; move the window to the center of the desktop
ResizeWindow(0, xPos, yPos, #PB_Ignore, #PB_Ignore)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
If IsIconic_(WindowID(0))
MessageRequester("Information","Window is minimized")
ShowWindow_(WindowID(0),1)
;now it's a good time to save the window size and position if needed
Else
MessageRequester("Information","Window is not minimized")
EndIf
EndIf
End
Franco