source: branches/delphi/ButtonB.pas

Last change on this file was 2, checked in by chronos, 7 years ago
File size: 1.4 KB
Line 
1unit ButtonB;
2
3interface
4
5uses
6 ButtonBase,
7 WinProcs, Classes, Graphics;
8
9type
10 TButtonB = class(TButtonBase)
11 constructor Create(aOwner: TComponent); override;
12 private
13 FMask: TBitmap;
14 FIndex: integer;
15 procedure SetIndex(x: integer);
16 public
17 property Mask: TBitmap read FMask write FMask;
18 published
19 property Visible;
20 property ButtonIndex: integer read FIndex write SetIndex;
21 property OnClick;
22 protected
23 procedure Paint; override;
24 end;
25
26procedure Register;
27
28implementation
29
30procedure Register;
31begin
32RegisterComponents('Samples', [TButtonB]);
33end;
34
35constructor TButtonB.Create;
36begin
37inherited Create(aOwner);
38ShowHint:=true;
39SetBounds(0,0,25,25);
40end;
41
42procedure TButtonB.Paint;
43begin
44with Canvas do
45 if FGraphic<>nil then
46 begin
47 BitBlt(Canvas.Handle,0,0,25,25,FGraphic.Canvas.Handle,
48 169,243+26*Byte(FDown),SRCCOPY);
49 if FIndex>=0 then
50 begin
51 BitBlt(Canvas.Handle,0,0,25,25,FMask.Canvas.Handle,
52 1+FIndex mod 12 *26,337+FIndex div 12 *26,SRCAND);
53 BitBlt(Canvas.Handle,0,0,25,25,FGraphic.Canvas.Handle,
54 1+FIndex mod 12 *26,337+FIndex div 12 *26,SRCPAINT);
55 end
56 end
57 else begin Brush.Color:=$0000FF; FrameRect(Rect(0,0,25,25)) end
58end;
59
60procedure TButtonB.SetIndex(x: integer);
61begin
62if x<>FIndex then
63 begin
64 FIndex:=x;
65 Invalidate
66 end
67end;
68
69end.
70
Note: See TracBrowser for help on using the repository browser.