1 | unit ButtonA;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | ButtonBase,
|
---|
7 | WinProcs, Classes, Graphics;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TButtonA = class(TButtonBase)
|
---|
11 | constructor Create(aOwner: TComponent); override;
|
---|
12 | private
|
---|
13 | FCaption: string;
|
---|
14 | procedure SetCaption(x: string);
|
---|
15 | procedure SetFont(const x: TFont);
|
---|
16 | published
|
---|
17 | property Visible;
|
---|
18 | property Caption: string read FCaption write SetCaption;
|
---|
19 | property OnClick;
|
---|
20 | public
|
---|
21 | property Font: TFont write SetFont;
|
---|
22 | protected
|
---|
23 | procedure Paint; override;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | procedure Register;
|
---|
27 |
|
---|
28 | implementation
|
---|
29 |
|
---|
30 | procedure Register;
|
---|
31 | begin
|
---|
32 | RegisterComponents('Samples', [TButtonA]);
|
---|
33 | end;
|
---|
34 |
|
---|
35 | constructor TButtonA.Create;
|
---|
36 | begin
|
---|
37 | inherited Create(aOwner);
|
---|
38 | FCaption:='';
|
---|
39 | SetBounds(0,0,100,25);
|
---|
40 | end;
|
---|
41 |
|
---|
42 | procedure TButtonA.Paint;
|
---|
43 | begin
|
---|
44 | with Canvas do
|
---|
45 | if FGraphic<>nil then
|
---|
46 | begin
|
---|
47 | BitBlt(Canvas.Handle,0,0,100,25,Graphic.Canvas.Handle,
|
---|
48 | 195,243+26*Byte(Down),SRCCOPY);
|
---|
49 | Canvas.Brush.Style:=bsClear;
|
---|
50 | Textout(50-(TextWidth(FCaption)+1) div 2,12-textheight(FCaption) div 2,
|
---|
51 | FCaption);
|
---|
52 | end
|
---|
53 | else begin Brush.Color:=$0000FF; FrameRect(Rect(0,0,100,25)) end
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TButtonA.SetCaption(x: string);
|
---|
57 | begin
|
---|
58 | if x<>FCaption then
|
---|
59 | begin
|
---|
60 | FCaption:=x;
|
---|
61 | Invalidate
|
---|
62 | end
|
---|
63 | end;
|
---|
64 |
|
---|
65 | procedure TButtonA.SetFont(const x: TFont);
|
---|
66 | begin
|
---|
67 | Canvas.Font.Assign(x);
|
---|
68 | Canvas.Font.Color:=$000000;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | end.
|
---|
72 |
|
---|