title: Class Helper and Class Interceptor in Delphi XE2
body: <p>I have a piece of code as shown bellow :</p>
  
  <p>Interface section :</p>
  
  <pre><code>TControlOrganizer = class(TComponent)  // a kind of List of TControl
  private
    FList : TList;  //Handling list of TControl
    ..............
  end;
  
  TControlHelperAdd = class // Just for separating value entered by user and value produced by code
    private
      FOrganizer : TControlOrganizer;
      FOrigValue : String;
      FUserValue : String;
  end;
  
  TControlHelper = class helper for TControl  //Basic helper for TControl
    private
      class var
        FAddProp : TControlHelperAdd;
    protected
      procedure SetOrganizer(Value : TControlOrganizer);
      function getOrganizer:TControlOrganizer;
    public
      class Constructor doinit;
      class Destructor deinit;
      procedure OrganizerChanged;virtual;
    published
      Property Organizer:TControlOrganizer read getOrganizer write setOrganizer; //Problem No.1
    end;
  
  //Helper for CustomEdit inherited from TControlHelper
  TCustomEditHelper = class helper(TControlHelper) for TCustomEdit
    protected
      procedure OrganizerChanged;override;
    end;
  //TEdit : interceptor
  TEdit= class(StdCtrls.TEdit)
    protected
      procedure Change;override;  //problem No.3
  end;
  </code></pre>
  
  <p>implementation section :</p>
  
  <pre><code>{TControlHelper}
  
  class Constructor TControlHelper.doinit;
  begin
    FAddProp :=TControlHelperAdd.Create;
  end;
  
  class Destructor TControlHelper.deinit;
  begin
    FreeAndNil(FAddProp);
  end;
  
  procedure TControlHelper.OrganizerChanged;
  begin
  end;
  
  procedure TControlHelper.SetOrganizer(Value : TControlOrganizer);
  begin
    if FAddProp.FOrganizer&lt;&gt;value then begin
       if assigned(FAddProp.FOrganizer) then begin
         FAddProp.FOrganizer.remove(self);
       end;
       FAddProp.FOrganizer:=value;
       if assigned(FAddProp.FOrganizer) then begin
         FAddProp.FOrganizer.Add(self);
       end;
       OrganizerChanged;  //Problem No.2
    end;
  end;
  
  function TControlHelper.getOrganizer:TControlOrganizer;
  begin
    result:=FAddProp.FOrganizer;
  end;
  
  {TCustomEditHelper}
  procedure TCustomEditHelper.OrganizerChanged; //problem No.2
  begin
    if assigned(FAddProp) then begin
      if assigned(Organizer) then begin
        FAddProp.FOrigValue:=Text;
        FAddProp.FUserValue:=Text;
      end;
    end;
  end;
  
  {TEdit = Interceptor} 
  procedure TEdit.Change; //Problem No.3
  begin
    inherited Change;
    FAddProp.FUserValue:=Text;
  end;
  </code></pre>
  
  <p>I found 3 problems that i couldn't solve myself.</p>
  
  <p>Problem 1 : 
  Published property property does not show up in the Object Inspector. I think I made a mistake and forgot something here.</p>
  
  <p>problem 2 :
  overridden method from class helper as shown above didn't fire (didn't work).</p>
  
  <p>problem 3 :
  overridden method from interceptor class as shown above didn't fire (didn't work).</p>
  
  <p>Could anyone please help me find out what's wrong with that?
  Thanks for help and sorry for my poor English.</p>