Minimizing an MDI child window changes the order in which the forms appear in MDIChildren[]
. This indexed property always returns the active MDI child in MDIChildren[0]
. So, the cleanest way to do what you want is to take a copy of all the forms first, and then start minimizing.
var
i: Integer;
Forms: array of TForm;
....
SetLength(Forms, MDIChildCount);
for i := 0 to high(Forms) do
Forms[i] := MDIChildren[i];
for i := 0 to high(Forms) do
Forms[i].WindowState := wsMinimized;