On 3/20/07, Antonio Sanguigni <[EMAIL PROTECTED]> wrote:

2007/3/20, Graeme Geldenhuys <[EMAIL PROTECTED]>:
>
> Yeah, as everybody else stated. The Tag property should do the trick for
> you.
>
>
And, broadly speaking, it is not a good practice modifying an ancestor to
suite these needs. Tag property is good but, for example, if you would need
a string property for your class you can make something similar that is
following and to use TMyObject as ancestor for your classes.
For TComponent you can do the same and create a similar property for your
class. If inheriting is a problem remember that you can always use the
composition.

Slapshot

type
  { TMyObject }

  TMyObject = Class(TObject)

  private
    FMyProperty: string;
    procedure SetMyProperty(const AValue: string);
    public
      property MyProperty: string read FMyProperty write SetMyProperty
  end;

implementation

{ TMyObject }

procedure TMyObject.SetMyProperty(const AValue: string);
begin
  if FMyProperty=AValue then exit;
  FMyProperty:=AValue;
end;


I obviously didn't know about the .tag property or else I wouldn't have
asked but I fail to see why one can't change an ancestor. It has been done
before (by adding .tag for example) and my bet is it will be done again.

--

Ger

Reply via email to