-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathuForms.pas
144 lines (116 loc) · 2.54 KB
/
uForms.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
unit uForms;
interface
uses Classes, Types, Forms, Controls, mainLCL,
{$ifdef fpc}
fileUtil,
{$endif}
Dialogs;
function Form_Show(id: integer): Boolean; cdecl;
function Form_ShowModal(id: integer): Integer; cdecl;
function Form_Hide(id: integer): Boolean; cdecl;
function Form_ShowOnTop(id: integer): Boolean; cdecl;
function Form_SendToBack(id: integer): Boolean; cdecl;
function Form_Close(id: integer): Boolean; cdecl;
function Form_Parent(id, parent: integer): Integer; cdecl;
function Form_Icon(id: integer; fileName: PWideChar): Integer; cdecl;
function Form_Create(app: integer): Integer;
procedure SetAsMainForm(aForm:integer);
implementation
function toForm(id: integer): TForm;
begin
Result := TForm(toObject(id));
end;
procedure SetAsMainForm(aForm:integer);
var
P: Pointer;
begin
P := @Forms.Application.Mainform;
Pointer(P^) := toForm( aForm );
end;
function Form_Show(id: integer): Boolean; cdecl;
begin
try
Result := true;
toForm(id).show();
except
Result := false;
end;
end;
function Form_ShowModal(id: integer): Integer; cdecl;
begin
Result := toForm(id).ShowModal();
end;
function Form_Hide(id: integer): Boolean; cdecl;
begin
try
Result := true;
toForm(id).hide();
except
Result := false;
end;
end;
function Form_ShowOnTop(id: integer): Boolean; cdecl;
begin
try
Result := true;
toForm(id).BringToFront();
except
Result := false;
end;
end;
function Form_SendToBack(id: integer): Boolean; cdecl;
begin
try
Result := true;
toForm(id).SendToBack();
except
Result := false;
end;
end;
function Form_Close(id: integer): Boolean; cdecl;
begin
try
Result := true;
toForm(id).Close();
except
Result := false;
end;
end;
function Form_Parent(id, parent: integer): Integer; cdecl;
begin
try
if parent = -1 then
Result := toID(toForm(id).Parent)
else begin
Result := 1;
toForm(id).Parent := toWControl(parent);
end;
except
Result := 0;
end;
end;
function Form_Icon(id: integer; fileName: PWideChar): Integer; cdecl;
var
Frm: TForm;
Str: String;
begin
Result := 0;
Frm := toForm(id);
Str := fileName;
if (file_exists(Str)) then begin
Frm.Icon.LoadFromFile(Str);
end;
end;
function Form_Create(app: integer): Integer;
var
form: TForm;
begin
form := TForm.CreateNew(TComponent(toObject(app)),0);
{if Application.MainForm = nil then begin
SetAsMainForm(Form);
Application.Initialize;
Randomize;
end;}
Result := toID( form );
end;
end.