unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TGraphicControl1 =
class
(TGraphicControl)
private
FNum:
Integer
;
procedure
SetNum(
const
Value:
Integer
);
protected
procedure
Paint; override;
public
property
Num:
Integer
read FNum
write
SetNum;
end
;
TForm1 =
class
(TForm)
procedure
FormCreate(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TGraphicControl1
.
Paint;
begin
Canvas
.
Brush
.
Color:=clWhite;
Canvas
.
FillRect(ClientRect);
Canvas
.
Font
.
Size:=
14
;
Canvas
.
Font
.
Color:=clBlack;
Canvas
.
TextOut(
10
,
10
, IntToStr(FNum));
end
;
procedure
TGraphicControl1
.
SetNum(
const
Value:
Integer
);
begin
if
Value<>FNum
then
begin
FNum:=Value;
Invalidate;
end
;
end
;
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
with
TGraphicControl1
.
Create(Self)
do
begin
Parent:=Self;
Left:=
100
;
Top:=
100
;
Width:=
100
;
Height:=
100
;
Num:=
$10000
;
end
;
end
;
end
.