你可以测试一下:  private
    { Private declarations }
    FMainMenu: TMainMenu; 
    procedure SetMainMenu(const Value: TMainMenu);  published
    { Published declarations }
    property MainMenu: TMainMenu read FMainMenu write SetMainMenu;
procedure TXXXMenu.SetMainMenu(const Value: TMainMenu);
begin
  if Value = FMainMenu then exit;
  FMainMenu := Value;
end;   安装后,做一个测试程序,步骤:1、在窗体上拖放这个控件 XXXMenu12、在窗体上拖放控件 MainMenu13、设置xxxMenu1的MainMenu为MainMenu14、ctrl+x 剪切掉MainMenu1,在点击xxxMenu1控件,出现内存错误,并且   原来的MainMenu属性也不见了,变成了其他的你也可以测试其他的标准控件,如:TActionList、TEdit、TPopMenu等等我感觉是setMainMenu方法出现问题,但又不知道如何改动,请指教!

解决方案 »

  1.   

    加上个
    procedure Notification(AComponent: TComponent;
          Operation: TOperation); override;
    procedure TxxxMenu1.Notification(AComponent: TComponent;
          Operation: TOperation); override;
    begin
      inherited Notification(AComponent, Operation);
      if Operation = opRemove then
        if AComponent = FMainMenu then FMainMenu := nil;
    end;
      

  2.   

    又学了一样
    谢谢xzgyb(老达摩)
      

  3.   


      private
        { Private declarations }
        FMainMenu: TMainMenu; 
        procedure SetMainMenu(const Value: TMainMenu);
     //增加下面过程
      protected
        procedure Notification(AComponent: TComponent; Operation: TOperation);   override;
      published
        { Published declarations }
        property MainMenu: TMainMenu read FMainMenu write SetMainMenu;procedure TXXXMenu.Notification(AComponent: TComponent;
      Operation: TOperation);
    begin
      inherited Notification(AComponent, Operation);
      
      if (AComponent = FMainMenu) and (Operation = opRemove) then
        FMainMenu:= nil;
      end;保证ok,给分!
      

  4.   

    private
        { Private declarations }
        FMainMenu: TMainMenu; 
        procedure SetMainMenu(const Value: TMainMenu);
    public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      published
        { Published declarations }
        property MainMenu: TMainMenu read FMainMenu write SetMainMenu;constructor TXXXMenu.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
    end;destructor TXXXMenu.Destroy;
    begin
      inherited Destroy;
    end;procedure TXXXMenu.SetMainMenu(const Value: TMainMenu);
    begin
      if Value = FMainMenu then exit;
      FMainMenu := Value;
    end;   
      

  5.   

    被 xzgyb(老达摩) 抢先一步!
      

  6.   

    unit Unit2;interfaceuses
      Classes, menus;
    type
      tmycontrol = class(TComponent)
      private
        FMainMenu: TMainMenu;
      protected
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
      public
        procedure SetMenu(const Value: TMainMenu);  published
        property MainMenu: TMainMenu read FMainMenu write FMainMenu;end;procedure Register;
    implementation{ tmycontrol }procedure Register;
    begin
      RegisterComponents('lsq', [tmycontrol]);
    end;procedure tmycontrol.Notification(AComponent: TComponent; Operation: TOperation);
    begin
      inherited;
      if (AComponent.ClassName = TMainMenu.ClassName)
         and (Operation = opRemove) then
      begin
        FMainMenu := nil;
      end;
    end;procedure tmycontrol.SetMenu(const Value: TMainMenu);
    beginend;end.
      

  7.   

    真受不了,大家如饥似渴呀,
    刚回答问题时,一个人也没有。
    等回复了,已被xzgyb(老达摩)抢先。
    发一句:被 xzgyb(老达摩) 抢先一步!
    发现又有两位。
      

  8.   

    SetMainMenu没问题不过FMainMenu 指向的对象已经不存在了,被你删了,所以出错
      

  9.   


    csvmm,那就在问个问题吧
      

  10.   

    xzgyb(老达摩)   两只眼睛瞪得跟两颗星星似的等的你分呢,哈哈
      

  11.   

    xzgyb(老达摩) 你是不是每天光在csdn上。
    我记得你呀!
    你是被我骗的第一人呀!
     喜欢delphi 的朋友进来看,告诉你一个秘密! 我也喜欢delphi~~~~~~ 哈,被骗,属我最傻
    你回答问题这么快,你不是第一个谁是第一个呀!
    嘿嘿~~
      

  12.   

    qwertyasd(昊):
    我到差点忘了

    还没找你算帐哩
    呵呵citytramper(阿琪):
    现在也不是想要分了
    因为要混到三颗星对于我来说是不可能了
    呵呵
      

  13.   

    csvmm:我这有个bcb版的cker和bcb_fans写的
    自动放分机
    比较好用
    我一般就用它结贴
    非常方便
    要不要
      

  14.   

    好啊,谢谢![email protected]我在公司上网受限制,象QQ、蚂蚁之类的东东都不能用,不知这个东东怎么样?
    ----------------------------我刚开了个散分帖,请各位老大畅谈!http://expert.csdn.net/Expert/topic/1672/1672392.xml?temp=.6002313
      

  15.   

    xzgyb(老达摩) 
    开玩笑的,哈哈,放分机能不能给我也发一个,谢谢了 [email protected]