var
i,count:integer;
begin
count:=0;
for i:=0 to application.ComponentCount-1 do
begin
if application.Components is TForm then
begin
inc(count);
listbox1.items.add(application.Components.Name);
end;
end;
showmessage(format('窗体为:%d',[count]))
end;
这样写
var
i,count:integer;
begin
count:=0;
for i:=0 to self.ComponentCount-1 do
begin
if self.Components is TForm then
begin
inc(count);
listbox1.items.add(self.Components.Name);
end;
end;
showmessage(format('窗体为:%d',[count]))
end;