假设这个窗体为Form1: TForm1在Close的事件写上Form1:=nil;其它需要调用本窗体的地方用if Form1=nil 即可

解决方案 »

  1.   

    try
      tempForm:=TFormxxx.Create(nil);
      with tempForm do
      begin
         //do somthing...
      end;
    finally
      tempForm.Free;
      tempForm:=nil;
    end;
      

  2.   

    方法很多啊,
    只说一种简单的,
    如果每个窗口的标题不同的话,
    你可以用api函数windows.foundwindow('类名','窗口标题')
    如果返回的值大于0,则窗口已经存在了!
    eg:
       if Windows.FindWindow('TForm1','Form1')>0 then
       begin  
          showmessage('已存在');
       end
       else
          begin
            ...........
          end;
       end;
      

  3.   

    if form1<>nil then
    begin
      ShowMessage('form1已经存在了。');
    end;
      

  4.   

    最简单的方法:
    Form1.Free;                    ////  Free会自动检查是否为空。
    Form1.Create(Application);
      

  5.   

    if screen[i].formname='youformname' then.....
      

  6.   

    if findComponent('Form1')<>nil then ShowMessage('窗口已创建!');
      

  7.   

    to largewang:多个实例!
    为什么窗体被free之后,其值不为nil,如果我直接给其赋值nil,是否会引起内存泄漏?
      

  8.   

    在创建窗体后可以将Tag付以不同的值来判断“某一”窗体,在FindWindow判断.
    如果创建参数为Application则不用Free(最好用此办法,在Application释放时自动释放资源),若参数为Nil,则要Free(后果你知道了).