我试了无问题的. form1 为 MainForm, form2.Formstyle = fsNamorl; form1 加上一 Button1, 事件 Button1OnClik: begin Form2 := TForm.Create(Self); //也可不用 if Form2.Showmodal = mrOK then showmessage('aaaaaa'); Form2.Free;
end;
form1 为 MainForm, form2.Formstyle = fsNamorl; form1 加上一 Button1, 事件 Button1OnClik: begin if not assigned(form2) then application.createform(Tform2.form2); if Form2.Showmodal = mrOK then showmessage('aaaaaa'); Form2.Free; form2:=nill;
form1 加上一 Button1,
事件 Button1OnClik:
begin
Form2 := TForm.Create(Self); //也可不用
if Form2.Showmodal = mrOK then
showmessage('aaaaaa');
Form2.Free;
end;
form1 为 MainForm, form2.Formstyle = fsNamorl;
form1 加上一 Button1,
事件 Button1OnClik:
begin
if not assigned(form2) then application.createform(Tform2.form2);
if Form2.Showmodal = mrOK then
showmessage('aaaaaa');
Form2.Free;
form2:=nill;
end;
另外:form2中的Onshow事件中不允许存在set focus 等不应在此执行的事件