i have this Abstract Base Unit :
unit UBase;
interface
uses
System.Classes;
type
TBaseAbstract = class(TComponent)
procedure Method(aObjectEvent: TNotifyEvent); virtual; abstract;
end;
TConcrete = class(TBaseAbstract)
procedure Method(aObjectEvent: TNotifyEvent); override;
strict private
fReadOnlyProperty: string;
public
constructor New(aValue: string; aOwner: TComponent);
destructor Destroy; override;
property ReadOnlyProperty: string Read fReadOnlyProperty; // Read Only Property ..
end;
implementation
{ TConcrete }
destructor TConcrete.Destroy;
begin
inherited;
end;
procedure TConcrete.Method(aObjectEvent: TNotifyEvent);
begin
aObjectEvent(Self)
end;
constructor TConcrete.New(aValue: string; aOwner: TComponent);
begin
inherited Create(aOwner);
fReadOnlyProperty := aValue + Self.ClassName +' ] '+ sLineBreak +
'Object Instance Name is: [' + Self.Name +' ]';
end;
end.
in my App Demo Main Form i have this:
var
FrmMain: TFrmMain;
implementation
uses
UBase;
var
fConcrete: TConcrete;
fBASE: TBaseAbstract;
{$R *.dfm}
procedure TFrmMain.FormCreate(Sender: TObject);
begin
fConcrete := TConcrete.New('i''m a Read Only PROPERTY of [ ', Self);
end;
procedure TFrmMain.FormDestroy(Sender: TObject);
begin
fConcrete.Free;
end;
procedure TFrmMain.Btn_Normal_EventClick(Sender: TObject);
begin
ShowMessage('i''m an Event of [ ' + Sender.ClassName +' ] '+ sLineBreak +
' And My Object Instance Name IS: [ ' + TComponent(Sender).Name +' ]');
end;
procedure TFrmMain.Btn_Call_MethodClick(Sender: TObject);
begin
fBASE := TConcrete.Create(nil);
try
fBASE.Method(Btn_Normal_Event.OnClick);
finally
fBASE.Free;
end;
end;
procedure TFrmMain.Btn_Call_Abstract_MethodClick(Sender: TObject);
begin
fConcrete.Method(Btn_Normal_Event.OnClick);
end;
procedure TFrmMain.Btn_Get_Concret_PropertyClick(Sender: TObject);
begin
ShowMessage(fConcrete.ReadOnlyProperty);
end;
end.
Btn_Normal_EventClick work correctlly (i got the name of this button when i click on it [Btn_Normal_Event])
but from fConcrete or fBase whether using Abstract Method or GetProperty the NAME IS EMPTY !!!
------------
do i missing something ?