如何判断一个窗体对象是否被创建?

解决方案 »

  1.   

    if assign(Form1) then  //created
    ..
      

  2.   

    TScreen.CustomForms可以获得所有已创建的TFrom,查看其ClassName属性是否为指定的Form类就OK了,如
    var nLoop: Integer
    ...
    for nLoop := 0 to Screen.CustomFormCount - 1 do
    if Screen.CustomForms[nLoop].ClassName = '你需要的窗体类名' then ...
      

  3.   

    错了,更正:if Assigned(Form1) then  //created
    ...
      

  4.   

    Assigned
    较为简单,不过在窗体销毁时最好用
    FreeAndNil()
      

  5.   

    findwindow()
    参数我不记得了,
      

  6.   

    if Assigned(窗体类名) then
      

  7.   

    if Assigned(窗体类名) then
      

  8.   

    麻烦一点遍历所有的对象
    不过还是感觉ASSIGN好一些
      

  9.   

    我用的是 
    if 窗体名=Null then
     ...但是要在此窗体關閉時要付為Null窗体名:=Null; 
    不知你想不想用
      

  10.   

    if Assigned(对象) then
      

  11.   

    if Application.FindComponent(Form2.Name)=nil then
        showmessage('尚未创建!')
      else begin
        showmessage('已经创建!');
        Form2.Destroy;
      end;//Form2-》'已经创建!'-》'尚未创建!'