Board index » delphi » minimize all active forms

minimize all active forms

I've five active forms and i need to iconize them in one touch!
TScreen help me giving me the number of the forms of my application so
i make a loop and i try to minimize the forms but at random one of the
forms if forgotten by the application why ?
why don't you try by your self!

this is my code:

var
   i : short;
begin
     for i := 0 to Screen.FormCount - 1 do
     begin
          if ((Screen.Forms[I].Visible) and
          (Screen.Forms[I].WindowState <> wsMinimized)) then
                  Screen.Forms[I].WindowState := wsMinimized;
     end;

 

Re:minimize all active forms


Quote
Paolo Papetti wrote:

> I've five active forms and i need to iconize them in one touch!
> TScreen help me giving me the number of the forms of my application so
> i make a loop and i try to minimize the forms but at random one of the
> forms if forgotten by the application why ?
> why don't you try by your self!

> this is my code:

> var
>    i : short;
> begin
>      for i := 0 to Screen.FormCount - 1 do
>      begin
>           if ((Screen.Forms[I].Visible) and
>           (Screen.Forms[I].WindowState <> wsMinimized)) then
>                   Screen.Forms[I].WindowState := wsMinimized;
>      end;

Screen.Forms[0] is the active form. When you minimize it, another is
activated and becomes screen.forms[0]. This form won't be minimized, as
your loop has already passed 0.

Change the for statement to:
  for := Screen.FormCount-1 downto 0 do
  .
  .

Regards,

Erik.
--
Need a custom component? Late on a project? Could use an util?
DOS Device driver? A VxD? NT drivers or services?
Applications of any kind?
Low rates, fast delivery!

When responding to news postings, please CC a copy to my email address.
Thanks.
Erik Sperling Johansen <e...@info-pro.no>

Other Threads