我自编了一个控件,经安装试验,正常情况没有什么问题,
为了查错,代码几乎全删,只剩空架子,这种情况会出错:
  在IDE设计态:
  我的新控件ImageDisp1有一个属性.ImageList;
指向另一个标准控件对象: ImageList1,
ImageDisp1.ImageList----->ImageList1;
如果这时静态删掉ImageList1,IDE就弹出,RTL60.BPL出错;
不知如何解决此问题?
     我的代码没有什么大问题,因为只剩空架子;
     1.如何设法屏掉此错误,用TRY没用;
     2.被删的ImageList1会不会能发出什么消息或事件,
让我的控件知道它已被删掉了;求助!

解决方案 »

  1.   

    研究一下FreeNotification机制, 在属性的写方法中,把自己注册到属性对象的通知列表中,当属性对象被释放时会通知我们的控件
    procedure TZcGridCommandManager.SetHistory(const Value: TZcGridCommandManager);
    begin
      if FHistory <> Value then
      begin
        if FHistory <> nil then FHistory.RemoveFreeNotification(Self);
        FHistory := Value;
        if FHistory <> nil then FHistory.FreeNotification(Self);
      end;  
    end;// 重载基类的Notification方法
    procedure TZcGridCommandManager.Notification(AComponent: TComponent; Operation:
        TOperation);
    begin
      inherited;
      // 如果通知的对象是我们关心的属性对象,就把属性设为nil
      if (Operation = opRemove) and (AComponent = FHistory) then
        FHistory := nil;
    end;
    ==================================
    EjunGrid
    http://www.ejun.cn