2008. június 9., hétfő

How to iterate over the MDI child array


Problem/Question/Abstract:

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:


procedure TForm1.IterateOverMDIChildren;
var
  i: integer;
begin
  for i := MDIChildCount - 1 downto 0 do
  begin
    {do something with MDI child here}
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése