如何判断一个已经创建过的子窗口类,已被cafree

解决方案 »

  1.   

    可不可以判断为nil呢?呵呵呵,我是个新手可能不大懂呢
      

  2.   


    if not assigned(...) then
      

  3.   

    可以判断对象是否为nil
    用类似  if object<>nil then 的语句
    也可以使用 if Assigned(object) then
    两种方法基本上没有什么区别,喜欢用哪个看你的爱好
    但更多的delphi程序员更喜欢使用后者
      

  4.   

    if not Assigned(object) then
    begin
    Myobject:=Object.Create(Self);
    try
    Myobject.ShowModal;
    finally
     Myobject.free;
     Myobject:=nil;//此句是必须的!
    end;
    end;
      

  5.   

    两种方法都可以,试试吧
    try
        if form2=nil then form2:=tform2.Create(self);
        form2.ShowModal ;
      finally
        form2.Free;
        form2:=nil;
      end;var myobject:Tform;
    begin
    if not Assigned(form2) then
    begin
    Myobject:=tform2.Create(Self);
    try
    Myobject.ShowModal;
    finally
     Myobject.free;
     Myobject:=nil;//此句是必须的!
    end;我只会瞎说