Skip to content

Commit 3838058

Browse files
committed
Interface improvements
1 parent fb03d5e commit 3838058

File tree

3 files changed

+43
-32
lines changed

3 files changed

+43
-32
lines changed

Source/Windows/AllowedIPs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@
9393
192.168.3.12
9494
192.168.3.13
9595
192.168.3.14
96-
192.168.3.15
96+
192.168.3.15

Source/Windows/Unit1.dfm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ object Main: TMain
1616
Font.Style = []
1717
OldCreateOrder = False
1818
Position = poScreenCenter
19+
OnActivate = FormActivate
1920
OnCloseQuery = FormCloseQuery
2021
OnCreate = FormCreate
2122
OnDestroy = FormDestroy
@@ -135,7 +136,7 @@ object Main: TMain
135136
Left = 16
136137
Top = 104
137138
end
138-
object PopupMenu: TPopupMenu
139+
object PopupMenuApp: TPopupMenu
139140
Left = 48
140141
Top = 104
141142
object AboutBtn: TMenuItem

Source/Windows/Unit1.pas

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TMain = class(TForm)
1212
IdHTTPServer: TIdHTTPServer;
1313
CommandKeyEdt: TEdit;
1414
CommandLbl: TLabel;
15-
PopupMenu: TPopupMenu;
15+
PopupMenuApp: TPopupMenu;
1616
CloseBtn: TMenuItem;
1717
AboutBtn: TMenuItem;
1818
LineBtn: TMenuItem;
@@ -41,12 +41,13 @@ TMain = class(TForm)
4141
procedure CancelBtnClick(Sender: TObject);
4242
procedure AllowAnyIPsCBClick(Sender: TObject);
4343
procedure AllowedIPsMemoChange(Sender: TObject);
44+
procedure FormActivate(Sender: TObject);
4445
private
4546
procedure DefaultHandler(var Message); override;
4647
{ Private declarations }
4748
protected
4849
procedure IconMouse(var Msg: TMessage); message WM_USER + 1;
49-
procedure WMActivate(var Msg: TMessage); message WM_ACTIVATE;
50+
//procedure WMActivate(var Msg: TMessage); message WM_ACTIVATE;
5051
public
5152
procedure AppShow;
5253
procedure AppHide;
@@ -55,7 +56,7 @@ TMain = class(TForm)
5556

5657
var
5758
Main: TMain;
58-
RunOnce, DebugMode: boolean;
59+
DebugMode: boolean;
5960
WM_TASKBARCREATED: Cardinal;
6061
AllowClose: boolean = false;
6162
AllowedIPs: TStringList;
@@ -214,7 +215,8 @@ procedure TMain.IdHTTPServerCommandGet(AThread: TIdPeerThread;
214215
//CoUninitialize;
215216
end;
216217

217-
procedure Tray(ActInd: integer); // 1 - äîáàâèòü, 2 - èçìåíèòü, 3 - óäàëèòü
218+
type TTrayAction = (TrayAdd, TrayUpdate, TrayDelete);
219+
procedure Tray(TrayAction: TTrayAction);
218220
var
219221
NIM: TNotifyIconData;
220222
begin
@@ -223,14 +225,14 @@ procedure TMain.IdHTTPServerCommandGet(AThread: TIdPeerThread;
223225
Wnd:=Main.Handle;
224226
uId:=1;
225227
uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
226-
hIcon:=SendMessage(Application.Handle, WM_GETICON, ICON_SMALL2, 0);
228+
hIcon:=SendMessage(Main.Handle, WM_GETICON, ICON_SMALL2, 0);
227229
uCallBackMessage:=WM_USER + 1;
228230
StrCopy(szTip, PChar(Application.Title));
229231
end;
230-
case ActInd of
231-
1: Shell_NotifyIcon(NIM_ADD, @NIM);
232-
2: Shell_NotifyIcon(NIM_MODIFY, @NIM);
233-
3: Shell_NotifyIcon(NIM_DELETE, @NIM);
232+
case TrayAction of
233+
TrayAdd: Shell_NotifyIcon(NIM_ADD, @NIM);
234+
TrayUpdate: Shell_NotifyIcon(NIM_MODIFY, @NIM);
235+
TrayDelete: Shell_NotifyIcon(NIM_DELETE, @NIM);
234236
end;
235237
end;
236238

@@ -248,10 +250,8 @@ procedure TMain.FormCreate(Sender: TObject);
248250
Ini: TIniFile;
249251
begin
250252
Application.Title:=Caption;
251-
AppHide;
252253
WM_TASKBARCREATED:=RegisterWindowMessage('TaskbarCreated');
253-
Tray(1);
254-
SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
254+
//SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
255255

256256
if GetLocaleInformation(LOCALE_SENGLANGUAGE) = 'Russian' then begin
257257
IDS_ABOUT:='Î ïðîãðàììå...';
@@ -300,52 +300,54 @@ procedure TMain.IconMouse(var Msg: TMessage);
300300
case Msg.LParam of
301301
WM_LBUTTONDOWN:
302302
begin
303-
if IsWindowVisible(Main.Handle) then
304-
AppHide
305-
else
306-
AppShow;
303+
// Ñêðûâàåì PopupMenu, åñëè ïîêàçàí
304+
PostMessage(Handle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
305+
PostMessage(Handle, WM_LBUTTONUP, MK_LBUTTON, 0);
307306
end;
308307

308+
WM_LBUTTONDBLCLK:
309+
if IsWindowVisible(Handle) then AppHide else AppShow;
310+
309311
WM_RBUTTONDOWN:
310-
PopupMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
312+
PopupMenuApp.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
311313
end;
312314
end;
313315

314-
procedure TMain.WMActivate(var Msg: TMessage);
316+
{procedure TMain.WMActivate(var Msg: TMessage);
315317
begin
316318
if (Msg.WParam = WA_INACTIVE) then
317319
AppHide;
318320
inherited;
319-
end;
321+
end;}
320322

321323
procedure TMain.FormDestroy(Sender: TObject);
322324
begin
323325
AllowClose:=true;
324326
AllowedIPs.Free;
325-
Tray(3);
327+
Tray(TrayDelete);
326328
end;
327329

328330
procedure TMain.DefaultHandler(var Message);
329331
begin
330332
if TMessage(Message).Msg = WM_TASKBARCREATED then
331-
Tray(1);
333+
Tray(TrayAdd);
332334
inherited;
333335
end;
334336

335337
procedure TMain.AppHide;
336338
begin
337339
AllowClose:=true;
338-
ShowWindow(Handle, SW_HIDE);
340+
Tray(TrayAdd);
341+
ShowWindow(Main.Handle, SW_HIDE); // Ñêðûâàåì ïðîãðàììó
342+
ShowWindow(Application.Handle, SW_HIDE); // Ñêðûâàåì ñ ïàíåëè çàäà÷
339343
end;
340344

341345
procedure TMain.AppShow;
342346
begin
343-
if Main.AlphaBlend then begin
344-
Main.AlphaBlendValue:=255;
345-
Main.AlphaBlend:=false;
346-
end;
347-
ShowWindow(Handle, SW_SHOW);
347+
ShowWindow(Main.Handle, SW_SHOW); // Ïîêàçûâàåì ïðîãðàììó
348+
ShowWindow(Application.Handle, SW_SHOW); // Ïîêàçûâàåì ïðîãðàììó íà ïàíåëè çàäà÷
348349
SetForegroundWindow(Handle);
350+
Tray(TrayDelete);
349351
AllowClose:=false;
350352
end;
351353

@@ -363,8 +365,8 @@ procedure TMain.CloseBtnClick(Sender: TObject);
363365

364366
procedure TMain.AboutBtnClick(Sender: TObject);
365367
begin
366-
Application.MessageBox(PChar(Caption + ' 1.0' + #13#10 +
367-
IDS_LAST_UPDATE + ' 06.05.25' + #13#10 +
368+
Application.MessageBox(PChar(Caption + ' 1.0.2' + #13#10 +
369+
IDS_LAST_UPDATE + ' 29.10.25' + #13#10 +
368370
'https://r57zone.github.io' + #13#10 +
369371
'[email protected]'), PChar(IDS_ABOUT), MB_ICONINFORMATION);
370372
end;
@@ -392,7 +394,6 @@ procedure TMain.OkBtnClick(Sender: TObject);
392394
if IPSMemoChanged then
393395
AllowedIPsMemo.Lines.SaveToFile(ExtractFilePath(ParamStr(0)) + 'AllowedIPs.txt');
394396

395-
//AppHide;
396397
IdHTTPServer.Active:=false;
397398
WinExec(PChar(ParamStr(0)), SW_SHOW);
398399
AllowClose:=true;
@@ -414,4 +415,13 @@ procedure TMain.AllowedIPsMemoChange(Sender: TObject);
414415
IPSMemoChanged:=true;
415416
end;
416417

418+
procedure TMain.FormActivate(Sender: TObject);
419+
begin
420+
if Main.AlphaBlend then begin
421+
AppHide;
422+
Main.AlphaBlendValue:=255;
423+
Main.AlphaBlend:=false;
424+
end;
425+
end;
426+
417427
end.

0 commit comments

Comments
 (0)