Easy,
use abstraction ..
Do
this instead .. (However if you cannot change your base class you
are basically stuffed ... ).
eg
TMyBaseComponent =
class(TComponent)
private
FMyProp : string;
FOnMyEvent : TNotifyEvent;
private
FMyProp : string;
FOnMyEvent : TNotifyEvent;
protected
procedure SetMyProp( const
Value: String ); virtual;
procedure DoMyEvent;
virtual;
published
property MyProp : string read FMyProp write SetMyProp;
property OnMyEvent : TNotifyEvent read FOnMyEvent write FOnMyEvent;
end;
published
property MyProp : string read FMyProp write SetMyProp;
property OnMyEvent : TNotifyEvent read FOnMyEvent write FOnMyEvent;
end;
TMyDescendantComponent =
class(TMyBaseComponent)
protected
procedure SetMyProp( const
Value: String ); override;
procedure DoMyEvent;
override;
end;
end;
Then in
procedure
DoMyEvent;
begin
if Assigned( FOnMyEvent) then
FOnMyEvent( Self );
end;
Depending on how things are decalred/ used, you could also hide the base
versions of MyProp/MyEvent by having in the descendant your own versions, but
for anything that calls the base class directly you are
stuffed.
Myles.
-----Original Message-----G'Day All,
From: Donovan J. Edye [mailto:[EMAIL PROTECTED]]
Sent: Friday, 7 September 2001 11:23 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: [Q] Component Questions
If I have something like:
TMyBaseComponent = class(TComponent)
private
FMyProp : string;
FOnMyEvent : TNotifyEvent;
published
property MyProp : string read FMyProp write FMyProp;
property OnMyEvent : TNotifyEvent read FOnMyEvent write FOnMyEvent;
end;
TMyDescendantComponent = class(TMyBaseComponent)
How do you elegantly in the descendant:
1. Determine when MyProp is changed so that TMyDescendantComponent can take some specialised action
2. Determine when OnMyEvent is fired so that TMyDescendantComponent can take some specialised action
TIA-- Donovan
----------------------------------------------------------------------
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems [www.namsys.com.au]
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic = Class(None);
Heard just before the 'Big Bang': "...Uh Oh...."
----------------------------------------------------------------------
GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
replacement. Also includes freeware delphi windows explorer components.
----------------------------------------------------------------------