Why does the Delphi WindowState main form return as "wsNormal" when the window is minimized?

I have a monitoring application written in Delphi 7 that works on a part of an additional monitor. I would like it to restore itself to normal visibility if the window is minimized (for example, if I use the "Windows-D" command (view desktop) on the main monitor)

I tried this timer activated code every few seconds:

if (Mainform.WindowState <> wsNormal ) then Mainform.WindowState := wsNormal; {restore main window if minimized} 

This does not work. To debug it, I changed the code to write the Mainform.WindowState value to a file as the program started. The value remains wsNormal, even if the main form window is minimized. Why?

+6
source share
1 answer

Because the basic form is not minimized. When the application is minimized, VCL simply hides the main form. You can check if the application is minimized and restore it:

 if IsIconic(Application.Handle) then Application.Restore; 
+7
source

All Articles