if Form2=nil then 
 begin
  Form2:= TForm2.create();
  Form2.show;
  Form2.free;
 end;
这我样显示窗体,可是,只能在第一次运行时执行,等到把Form关了以后,就不能再打开了,这是为什么呀.大家帮我看看下.多谢了.

解决方案 »

  1.   

    改成
      Form2:= TForm2.create(Form1);
      Form2.show;
      Form2.free;
    就可以了,把if Form2=nil then 去掉
    因为在你执行过一次之后,Form2就不会=nil,所以不会执行if 之后的语句了
      

  2.   

    begin
      if not Assigned(Form2) then
        Form2 := TForm2.Create(Self);
      Form2.Show;
    end;在Form2的OnDestory事件写:
       Form2 := nil;
     
      

  3.   

    if Form2=nil then 
     begin
      Form2:= TForm2.create();
      Form2.show;
      Form2.free;
     end;明显不正确嘛,form2<>nil,那你不就没显示了吗?同意楼上,将 if Form2=nil then 删除即可。