1.界面
2.代码
form1 代码:
implementation
uses unit2; {$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var f2 :Tform2;
begin
f2 := Tform2.Create(self);
f2.flag :='1';
if f2.ShowModal = mrOk then
begin
Application.CreateForm(Tform,form2);
form2.ShowModal;
end;
end;
procedure TForm1.btn2Click(Sender: TObject);
var f2 :Tform2;
begin
f2 := Tform2.Create(self);
f2.flag :='2';
if f2.ShowModal = mrOk then
begin
Application.CreateForm(Tform,form2);
form2.ShowModal;
end;
end;
end.
form2 代码:
public
flag : String;//判断打开的是哪个窗体
{ Public declarations }
end;
var Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
begin
if flag = '1' then
caption := '打开了第一个窗体'
else if flag='2' then
caption := '打开了第二个窗体'
end;
end.