begin
  while MDIChildCount > 0 do
  begin
    MDIChildren[0].Close; 
  end;
end;
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

解决方案 »

  1.   

    var
      i:integer;
    begin
      for i:=0 to MDIChildCount-1 do
      begin
        if MDIChildren[i].Caption<>'aaa' then  MDIChildren[i].Close; 
      end;
    end;
    procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action := caFree;
    end;
      

  2.   

    var 
      intChildNum : integer;
    begin
      intChildNum:=ChildrenCount;//获得子窗体的个数,函数名忘记了,好象不是这个函数,自己找一下吧!
      for I:=intChildNum-1 downto 0 do
      begin
        if (TForm(MDIChildren[I])).caption<>"指定的Caption" then
          MDIChildren[0].Close; 
      end;
    end;
    procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action := caFree;
    end;
      

  3.   

    button执行action事件,每个子窗体与系统提供的windows类别action关联