-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmainLCL.pas
117 lines (94 loc) · 1.92 KB
/
mainLCL.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
unit mainLCL;
interface
uses
SysUtils, Controls, Classes, Types
{$ifdef fpc}
,fileUtil
{$endif}
;
function toID(o: TObject): integer;
function ToStr(S: PAnsiChar; Len: integer): ansistring; overload;
function ToStr(V: variant): ansistring; overload;
function ToStrA(V: variant): ansistring;
function ToPChar(V: variant): PAnsiChar;
function toObject(id: integer): TObject;
function toWControl(id: integer): TWinControl;
function toControl(id: integer): TControl;
function encStr(S: string): string;
function file_exists(const aFile: string): boolean;
var
fromANSI: boolean = False;
implementation
function file_exists(const aFile: string): boolean;
begin
{$ifdef fpc}
Result := FileExistsUTF8(aFile);
{$else}
Result := FileExists(aFile);
{$endif}
end;
function encStr(S: string): string;
begin
if fromANSI then
s := AnsiToUtf8(s);
Result := s;
end;
function ToStrA(V: variant): ansistring;
begin
Result := V;
end;
function ToStr(S: PAnsiChar; Len: integer): ansistring; overload;
var
i: integer;
begin
Result := '';
for i := 0 to len - 1 do
begin
Inc(S);
Result := Result + s^;
end;
end;
function ToStr(V: variant): ansistring;
begin
Result := V;
end;
function ToPChar(V: variant): PAnsiChar;
begin
Result := PAnsiChar(ToStr(V));
end;
function toID(o: TObject): integer;
begin
if o = nil then
Result := 0
else
Result := integer(o);
end;
function toWControl(id: integer): TWinControl;
begin
if id = 0 then
Result := nil
else
Result := TWinControl(integer(id));
end;
function toControl(id: integer): TControl;
begin
if id = 0 then
Result := nil
else
Result := TControl(integer(id));
end;
function toComponent(id: integer): TComponent;
begin
if id = 0 then
Result := nil
else
Result := TComponent(integer(id));
end;
function toObject(id: integer): TObject;
begin
if id = 0 then
Result := nil
else
Result := TObject(integer(id));
end;
end.