-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPE.Msg.pas
More file actions
57 lines (42 loc) · 1.25 KB
/
PE.Msg.pas
File metadata and controls
57 lines (42 loc) · 1.25 KB
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
unit PE.Msg;
interface
type
TMsgProc = procedure(Text: PWideChar); stdcall;
TMsgMgr = record
private
FMsgProc: TMsgProc;
public
constructor Create(AMsgProc: TMsgProc);
procedure Write(const AText: UnicodeString); overload;
procedure Write(const AFmt: UnicodeString; const AArgs: array of const); overload;
procedure Write(const Category: string; AText: UnicodeString); overload;
procedure Write(const Category: string; AFmt: UnicodeString; const AArgs: array of const); overload;
end;
PMsgMgr = ^TMsgMgr;
implementation
uses
System.SysUtils;
{ TMessageMgr }
procedure TMsgMgr.Write(const AText: UnicodeString);
begin
if Assigned(FMsgProc) then
FMsgProc(PWideChar(AText));
end;
constructor TMsgMgr.Create(AMsgProc: TMsgProc);
begin
FMsgProc := AMsgProc;
end;
procedure TMsgMgr.Write(const AFmt: UnicodeString; const AArgs: array of const);
begin
Write(Format(AFmt, AArgs));
end;
procedure TMsgMgr.Write(const Category: string; AText: UnicodeString);
begin
write(Format('[%s] %s', [Category, AText]));
end;
procedure TMsgMgr.Write(const Category: string; AFmt: UnicodeString;
const AArgs: array of const);
begin
write(Category, Format(AFmt, AArgs));
end;
end.