-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUMsg.pas
101 lines (75 loc) · 1.71 KB
/
UMsg.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit UMsg;
interface
uses
Classes,Windows,Graphics,TetrixConst,Dialogs,SysUtils,Controls;
type
TMsg = class
private
Msg:TBitmap;
Text:String;
function GetCanvas:TCanvas;
protected
procedure Paint;
public
constructor Create(AOwner: TComponent;Str:string);
destructor Destroy; override;
function GetWidth:Integer;
function GetHeight:Integer;
procedure Show(Str:String);
property Canvas:TCanvas Read GetCanvas;
end;
implementation
{ TMsg }
constructor TMsg.Create(AOwner: TComponent; Str: string);
begin
Msg:= TBitmap.Create;
Msg.Width:= 220;
Msg.Height:=120;
end;
destructor TMsg.Destroy;
begin
inherited;
Msg.Free;
end;
function TMsg.GetCanvas: TCanvas;
begin
Result:= Msg.Canvas;
end;
function TMsg.GetHeight: Integer;
begin
Result:= Msg.Height;
end;
function TMsg.GetWidth: Integer;
begin
Result:= Msg.Width;
end;
procedure TMsg.Paint;
var
TW:Integer;
begin
with Msg.Canvas do
begin
Brush.Color:= ClRed;
Pen.Width:=3;
Pen.Color:=ClBlack;
Pen.Style:= psSolid;
brush.Color:= RGB(80,80,80);
Rectangle(0,0,Msg.Width,Msg.Height);
Font.Name:= 'Tahoma';
Font.Size:= 22;
Font.Color:= clSilver;
TW:= (Msg.Width div 2) - ((Length(Text) * (Font.Size div 2) + (Font.Size div 4)*8 + (Font.Size div 8)*8) div 2);
TextOut(TW,5,Text);
Font.Size:= 18;
Font.Color:= clGray;
Text:= 'Press Enter';
TW:= (Msg.Width div 2) - ((Length(Text) * (Font.Size div 2) + (Font.Size div 4)*6 + (Font.Size div 8)*6) div 2);
TextOut(TW,70,Text);
end;
end;
procedure TMsg.Show(Str: String);
begin
Text:= Str;
Paint;
end;
end.