for i := 0 to Application.ComponentCount - 1 do
      begin
      ... 
      end;这个Application.ComponentCount 到底指的是哪些组件的个数总和,包括不包括非auto-create的form及其上面的组件.

解决方案 »

  1.   

    包括所有生成的form,但不包括组件,另外还有一个系统window测试:
    var i:integer;
    begin
    for   i:=0 to application.ComponentCount-1 do
    showmessage(application.Components[i].ClassName)
    end;
      

  2.   

    比如,主窗体是form1,我动态创建了form2,form2上面有一个edit,这个edit算不算?
      

  3.   

    只包括生成的FORM,不包括组件。
    form2上面的edit组件不算。
    刚刚测试过
      

  4.   

    来晚了。
    包括以Application为直接宿主的所有控件。
      

  5.   

    同意楼上var T:Tedit;
    begin
      T:=Tedit.Create(nil);
      T.Parent:=self;
    end;
    这个动态的不包括
    var T:Tedit;
    begin
      T:=Tedit.Create(application);
      T.Parent:=self;
    end;
    这个包括
      

  6.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons;type
      TForm1 = class(TForm)
        BitBtn1: TBitBtn;
        procedure BitBtn1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var i:integer;
    begin
    showmessage(inttostr(application.Componentcount));
    for   i:=0 to application.ComponentCount-1 do
    showmessage(application.Components[i].ClassName);
    end;
    end.
    结果show出来的是2个,一个是tform,一个是thintwindow?后者是什么?每次都会自动创建吗/