-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tray.pas
48 lines (39 loc) · 1.14 KB
/
Tray.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
unit Tray;
interface
uses Windows, ShellAPI, Messages, SysUtils;
const
WM_MYICONNOTIFY=WM_USER+123;
procedure CreateTrayIcon(Handle:HWND; IHandle:HWND;
n:Integer);
procedure DeleteTrayIcon(Handle:HWND; n:Integer);
implementation
procedure CreateTrayIcon(Handle:HWND; IHandle:HWND;
n:Integer);
var NIData:TNotifyIconData;
begin
with NIData do begin
cbSize:=SizeOf(TNotifyIconData);
{HWND íàøåãî îêíà (îêíà, ïðèíèìàþùåãî îáðàòíûå
ñîîáùåíèÿ)}
Wnd:=Handle;
uID:=n; //íîìåð çíà÷êà
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage:=WM_MYICONNOTIFY; //îáðàòíîå ñîîáùåíèå
{òî, îòêóäà ñä¸ðãèâàåòñÿ çíà÷îê ýòî ìîæåò áûòü è
ImageList è ò.ä.}
hIcon:=IHandle;
StrPCopy(szTip,'Ñâîáîäíîå ìåñòî íà íåñìåííûõ äèñêàõ'); //âñïëûâàþùàÿ ñòðîêà
end;
Shell_NotifyIcon(NIM_ADD,@NIData); //äîáàâëåíèå çíà÷êà
end;
procedure DeleteTrayIcon(Handle:HWND; n:Integer);
var NIData:TNotifyIconData;
begin
with NIData do begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle;
uID:=n;
end;
Shell_NotifyIcon(NIM_DELETE,@NIData); //óäàëåíèå çíà÷êà
end;
end.