我怎么判断一个MDI字窗体是否存在?如果存在只是显示不用再建立?

解决方案 »

  1.   

    function MDIChild_HasCreated(Father:TForm;Child_ClassName:string):Boolean;
    var
      i:Integer;
    begin
      Result:=true;
      for i := 0 to Father.MDIChildCount-1 do
      begin
       if Father.MDIChildren[i].ClassName = Child_ClassName then
       begin
         Father.MDIChildren[i].WindowState:=wsNormal;
         Result:=false;
       end;
      end;end;
      

  2.   

    if not Assigned(Form1) then
         Form1:=TForm1.Create(Application);
      Form1.Show;
      

  3.   

    谢谢 zzllabc(清心释累,绝率忘情)
      

  4.   

    insert2003(高级打字员):方法不行,如果将窗体关掉再打开就会出错
      

  5.   

    怎么会呢?关闭时要释放Form1的onClose事件Action := caFree;onDestroy事件Form1 := nil;
      

  6.   

    onDestroy事件  加上
     
    Form1  :=  nil; 
    就可以,谢谢insert2003