Registriert seit: 3. Mai 2003
140 Beiträge
Delphi 2006 Enterprise
|
Re: Meine erste Kompo: Problem mit dem Changeereignis
22. Mär 2004, 20:28
Hallo,
Du brauchst natürlich einen Setter für die Property Value.
mr2
Delphi-Quellcode:
TIntegerComponent = class(TComponent)
private
FValue: Integer; // besser Integer nehmen & alles was mit 'F' beginnt immer private lassen!
FOnValueChange: TValueChangeEvent;
procedure SetValue(NewValue: Integer);
{ Private-Deklarationen } // diese Kommentare sollten immer am Ende eines Blocks stehen
published
property OnValueChange: TValueChangeEvent read FOnValueChange write FOnValueChange;
property Value: Integer read FValue write SetValue;
{ Published-Deklarationen }
end;
procedure TIntegerComponent.SetValue(NewValue: Integer);
begin
if (NewValue <> FValue)
then begin
if Assigned(FOnValueChange)
then FOnValueChange(Self, FValue);
FValue := NewValue;
end;
end;
"... we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we don't know. But there are also unknown unknowns - the ones we don't know we don't know."
|