-
Notifications
You must be signed in to change notification settings - Fork 78
/
ufrmMain.pas
130 lines (107 loc) · 2.85 KB
/
ufrmMain.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
unit ufrmMain;
interface
uses
SysUtils, Windows,Messages,
Classes,
Controls, Forms, SkinData, DynamicSkinForm,
uCEFChromium,
uframeChrome,
Dialogs, StdCtrls, ExtCtrls, spTrayIcon, Menus, SkinMenus;
type
TfrmMain = class(TForm)
frameChrome1: TframeChrome;
DSF: TspDynamicSkinForm;
spTrayIcon1: TspTrayIcon;
spSkinPopupMenu1: TspSkinPopupMenu;
mnExitApp: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure spTrayIcon1DblClick(Sender: TObject);
procedure mnExitAppClick(Sender: TObject);
private
{ Private declarations }
// 加载主页,因为不能直接加载PHP,
procedure loadMainConfig();
protected
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
uses
unConfig, ufrmSplash, unMoudle, unChromeMessage, unCmdCli;
{$R *.dfm}
procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := frameChrome1.FCanClose;
if not(frameChrome1.FClosing) then
begin
frameChrome1.FClosing := True;
Visible := False;
frameChrome1.Chromium1.CloseBrowser(True);
end;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
frmSplash := TfrmSplash.Create(nil);
try
if FileExists(unConfig.FIcon) then
Self.Icon.LoadFromFile(unConfig.FIcon);
frmSplash.Show;
Application.ProcessMessages;
// 1.加载配置
loadMainConfig();
// 2.加载皮肤
if FileExists(unConfig.FSkinFile) then
dbMoudle.spSkinData1.LoadFromCompressedFile(FSkinFile);
// 4.启动db数据服务器
// create_db_server();
// db_server_start(unConfig.FDataPort);
// 5.启动ws服务器
// create_ws_server();
// ws_server_start(unConfig.FWsPort,unConfig.FWebPort);
// 6.启动workerman
cmdCli := TCmdCli.Create;
//7. 启动检测是否最大化窗口
if(unConfig.FStartup_Max = 1) then
Self.WindowState := wsMaximized;
finally
frmSplash.Free;
end;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
// 停止Abs数据服务器
// db_server_stop();
// free_db_server();
// 停止ws服务器
// ws_server_stop();
// free_ws_server();
// 停止workerman服务
cmdCli.Free;
end;
procedure TfrmMain.FormShow(Sender: TObject);
begin
frameChrome1.setInfo(Self, unConfig.FIndexUrl);
end;
procedure TfrmMain.loadMainConfig;
begin
Self.Width := unConfig.FWidth;
Self.Height := unConfig.FHeight;
Self.Caption := unConfig.FCaption;
end;
procedure TfrmMain.mnExitAppClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TfrmMain.spTrayIcon1DblClick(Sender: TObject);
begin
Self.Show();
Self.WindowState := TWindowState.wsNormal;
Application.BringToFront(); // 前靠
end;
initialization
end.