for i=0 to Application.ComponentCount do
begin
if(Application->Components[i].Name =='Form1')then begin
TForm1(Application->Components[i]).Caption='123';
...
end;
end;
begin
if(Application->Components[i].Name =='Form1')then begin
TForm1(Application->Components[i]).Caption='123';
...
end;
end;
for i=0 to Application.ComponentCount do
begin
if(Application->Components[i].Name ='Form1')then begin
TForm1(Application->Components[i]).Caption := '123';
...
end;
end;
for i := 0 to Application.ComponentCount - 1 do
if Application.Components[i].Name = 'Form1' then
begin
TForm(Application.Components[i]).Caption := '123';
break;
end;
var
vFormClass: TFormClass;
begin
vFormClass := TFormClass(GetClass('TForm1')); //GetClass()返回根据名称搜索的类
if Assigned(vFormClass) then
with vFormClass.Create(Self) do try
ShowModal;
finally
Free;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterClass(TForm1); //需要注册
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterClass(TForm1); //注销
end;