var
Form1: TForm1;
frm:TForm;
str:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(TForm1, frm);
frm.show;
str:=frm.Name;//设定你要设置的form的选择条件
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for i:=0 to Application.ComponentCount-1 do
if TForm1(Application.Components[i]).Name=str then
TForm1(Application.Components[i]).Caption:='haha';
end;
用一个TScreen对象来作不是很难,代码如下:
var
AForm:TForm;
i:Integer;
begin
AForm:=nil;
for i:=0 to Screen.FormCount-1 do
if UpperCase(Screen.Forms[i].Name)='FORM2' then
begin
AForm:=Screen.Forms[i];
Break;
end;
if AForm<>nil then
AForm.ShowModal;
end;