-
Notifications
You must be signed in to change notification settings - Fork 2
/
PopupWindow.pas
201 lines (176 loc) · 4.56 KB
/
PopupWindow.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
unit PopupWindow;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ImgList, Buttons, ComCtrls, XPMan, InformWnd;
const
WM_MYMESSAGE = WM_USER + $7769;
type
TPopupWnd = class(TForm)
Label1: TLabel;
Label2: TLabel;
CloseImage: TImage;
Label3: TLabel;
Image2: TImage;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
AdditionalInfoLabel: TLabel;
DetectedLabel: TLabel;
RemovedLabel: TLabel;
LabelName: TLabel;
CloseTimer: TTimer;
procedure AdditionalInfoLabelClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CloseImageClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormHide(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure CloseTimerTimer(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure LabelNameClick(Sender: TObject);
procedure LabelNameMouseEnter(Sender: TObject);
procedure LabelNameMouseLeave(Sender: TObject);
public
AdditionInfoForm: TForm3;
ParentThread: TThread;
protected
procedure HandleMessage(var Msg: TMessage); message WM_MYMESSAGE;
end;
implementation
{$R *.dfm}
var
FormFreeTopPosition: array [0..255] of boolean;
FormLeftPosition: integer;
FormInitialBasePosition: integer;
procedure TPopupWnd.AdditionalInfoLabelClick(Sender: TObject);
begin
AdditionalInfoLabel.Enabled := false;
AdditionInfoForm.Show;
end;
procedure TPopupWnd.FormActivate(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
CloseTimer.Enabled := false;
Application.BringToFront;
end;
procedure TPopupWnd.FormCreate(Sender: TObject);
begin
AdditionInfoForm := TForm3.Create(Self);
AdditionInfoForm.Tag := Integer(Self);
Self.Font := Application.MainForm.Font;
end;
procedure InitFormPosition;
var
hWindow: HWND;
WindowRect: TRect;
begin
hWindow := FindWindow('Progman', nil);
GetWindowRect(hWindow, WindowRect);
FormLeftPosition := WindowRect.Right - 315;
hWindow := FindWindow('Shell_TrayWnd', nil);
GetWindowRect(hWindow, WindowRect);
FormInitialBasePosition := WindowRect.Top;
FillChar(FormFreeTopPosition, 256, True);
end;
procedure TPopupWnd.FormShow(Sender: TObject);
const
VertSpace = 10;
var
i: integer;
begin
for i := 0 to 255 do
if FormFreeTopPosition[i] then
begin
Self.Tag := i;
break;
end;
FormFreeTopPosition[Self.Tag] := false;
Self.Left := FormLeftPosition;
i := FormInitialBasePosition - (Self.Tag + 1) * (Self.Height + VertSpace);
Self.Top := i;
end;
procedure TPopupWnd.CloseImageClick(Sender: TObject);
begin
Close;
end;
procedure TPopupWnd.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Hide;
FormFreeTopPosition[Self.Tag] := true;
AdditionInfoForm.Free;
Release;
end;
procedure TPopupWnd.FormHide(Sender: TObject);
var
i: integer;
begin
i := 255;
while i > 0 do
begin
Self.AlphaBlendValue := i;
Sleep(1);
Application.ProcessMessages;
Dec(i, 16);
end;
end;
procedure TPopupWnd.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Assigned(ParentThread) then
begin
if (MessageDlg('Ïðîâåðêà åùå ïðîäîëæàåòñÿ. Õîòèòå îòìåíèòü ïðîâåðêó?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
ParentThread.Terminate
else
CanClose := false;
end;
end;
procedure TPopupWnd.CloseTimerTimer(Sender: TObject);
begin
Close;
end;
procedure TPopupWnd.HandleMessage(var Msg: TMessage);
begin
if Msg.LParam = 0 then
begin
if (ParentThread = nil) and AdditionalInfoLabel.Enabled then
CloseTimer.Enabled := true;
end
else
begin
if Self.Active then
CloseTimer.Enabled := false;
end;
end;
procedure TPopupWnd.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
SC_DRAGMOVE : Longint = $F012;
begin
if Button <> mbRight then
begin
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);
end;
end;
procedure TPopupWnd.LabelNameClick(Sender: TObject);
var
s: char;
begin
s := LabelName.Caption[Pos(':)', LabelName.Caption) - 1];
WinExec(PChar('explorer.exe ' + s + ':\'), SW_SHOW);
end;
procedure TPopupWnd.LabelNameMouseEnter(Sender: TObject);
begin
if (Sender as TLabel).Enabled then
(Sender as TLabel).Font.Style := [fsUnderline];
end;
procedure TPopupWnd.LabelNameMouseLeave(Sender: TObject);
begin
(Sender as TLabel).Font.Style := [];
end;
initialization
InitFormPosition;
end.