如何获得当前打开的子窗口的数量?

解决方案 »

  1.   

    以下可以求出当前创建好的窗体的个数:
    procedure TForm1.Button1Click(Sender: TObject);
    var I:integer;
    j:integer;
    begin
       //  for I := MDIChildCount-1 downto 0 do
       // MDIChildren[I].Close;     j:=0;
       for i:=0 to application.componentcount-1 do
       if (application.Components[i] is TForm) then
       begin
       if(application.Components[i] as Tform).Enabled=true then  /////把enabled改为visible以求当前可见的窗体的个数
       inc(j);
       end;
       showmessage(inttostr(j));
    end;
      

  2.   

    同意二楼的意见
    Application.MainForm.MDIChildCount,最简单直观