Author: Jonas Bilinkevicius
How to iterate over the MDI child array
Answer:
The documentation of TForm.MDIChildren[] states that the index of the first-created
MDI child is 0. This is incorrect - the index of the most-recently-created MDI
child is always 0, and the index of the first-created MDI child is always
MDIChildCount - 1. With this in mind, you can use the following code to iterate
over the MDI child array from from the first-created to the last:
1 procedure TForm1.IterateOverMDIChildren;
2 var3 i: integer;
4 begin5 for i := MDIChildCount - 1 downto 0 do6 begin7 {do something with MDI child here}8 end;
9 end;