Delphi-Quellcode:
procedure TFDFix.SetActive(const Value: Boolean);
begin
if Value = FActive then
Exit
else
begin
FActive := Value;
// ...
end;
end;
dann bitte aber so:
Delphi-Quellcode:
procedure TFDFix.SetActive(const Value: Boolean);
begin
if Value <> FActive then
begin
FActive := Value;
// ...
end;
end;
Borland/CodeGear/Embarcadero machen das auch so:
Ein schönes Beispiel ist TMargins und TPadding:
Delphi-Quellcode:
// Quelltext gekürzt !!!
TMarginSize = 0..MaxInt;
TMargins = class(TPersistent)
private
FLeft, FTop, FRight, FBottom: TMarginSize;
procedure SetMargin(Index: Integer; Value: TMarginSize);
protected
procedure Change; virtual;
published
property Left: TMarginSize index 0 read FLeft write SetMargin default 3;
property Top: TMarginSize index 1 read FTop write SetMargin default 3;
property Right: TMarginSize index 2 read FRight write SetMargin default 3;
property Bottom: TMarginSize index 3 read FBottom write SetMargin default 3;
end;
TPadding = class(TMargins)
published
property Left default 0;
property Top default 0;
property Right default 0;
property Bottom default 0;
end;
procedure TMargins.SetMargin(Index: Integer; Value: TMarginSize);
begin
case Index of
0:if Value <> FLeft then
begin
FLeft := Value;
Change;
end;
1:if Value <> FTop then
begin
FTop := Value;
Change;
end;
2:if Value <> FRight then
begin
FRight := Value;
Change;
end;
3:if Value <> FBottom then
begin
FBottom := Value;
Change;
end;
end;
end;