This is just a very simple example of a specific case, but still it is a very common case.
, /. , / BackgroundColor.
variable/ :
TMyControl = class(TCustomControl)
public
BackgroundColor: TColor;
...
end;
TMyControl.Paint , BackgroundColor. . , BackgroundColor , . , - .
, :
TMyControl = class(TCustomControl)
private
FBackgroundColor: TColor;
public
function GetBackgroundColor: TColor;
procedure SetBackgroundColor(NewColor: TColor);
...
end;
function TMyControl.GetBackgroundColor: TColor;
begin
result := FBackgroundColor;
end;
procedure TMyControl.SetBackgroundColor(NewColor: TColor);
begin
if FBackgroundColor <> NewColor then
begin
FBackgroundColor := NewColor;
Invalidate;
end;
end;
, , MyControl1.GetBackgroundColor MyControl1.SetBackgroundColor . .
, . ,
TMyControl = class(TCustomControl)
private
FBackgroundColor: TColor;
procedure SetBackgroundColor(NewColor: TColor);
published
property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor;
end;
...
procedure TMyControl.SetBackgroundColor(NewColor: TColor);
begin
if FBackgroundColor <> NewColor then
begin
FBackgroundColor := NewColor;
Invalidate;
end;
end;
- , ,
MyControl1.BackgroundColor - , !