在主表单中:
procedure TForm_main.TB_addrClick(Sender: TObject);
begin
if Form_addr=nil then
begin
datamoduleAll.Table_addr.Open;
if datamoduleAll.Table_addr.Active=true then
Form_addr:=TForm_addr_M.Create(Application) ;
Form_addr.Caption:='通讯录';
end
else
Form_addr.BringToFront;
end;
在子表单中:
procedure TForm_addr_M.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Free;
Form_addr:=nil;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if form2=nil then
begin
Application.CreateForm(TForm2, Form2);
form2.FormStyle :=fsstayontop;
form2.Show;
end;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form2:=nil;
action:=cafree;
end;