-
Notifications
You must be signed in to change notification settings - Fork 14
/
Tray.Helpers.pas
101 lines (87 loc) · 2.71 KB
/
Tray.Helpers.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
unit Tray.Helpers;
interface
uses
WinApi.Windows, Winapi.ShellAPI,
System.Types;
function IsNotifyIconOverflowWindowVisible: boolean;
function IsTaskbarAutoHideOn : boolean;
function GetNotifyIconOverflowWindow: HWND;
function GetTrayNotifyWndToolbar: HWND;
function GetTaskbarPos: TRect;
function GET_X_LPARAM(const lParam: LPARAM): Integer; inline;
function GET_Y_LPARAM(const lParam: LPARAM): Integer; inline;
implementation
function IsNotifyIconOverflowWindowVisible: boolean;
var
NotifyIconOverflowWindow: HWND;
begin
NotifyIconOverflowWindow := GetNotifyIconOverflowWindow;
if NotifyIconOverflowWindow = 0 then
Result := False
else
Result := IsWindowVisible(NotifyIconOverflowWindow);
end;
function IsTaskbarAutoHideOn : boolean;
var
ABData : TAppBarData;
begin
ABData.cbSize := sizeof(ABData);
Result := (SHAppBarMessage(ABM_GETSTATE, ABData) and ABS_AUTOHIDE) <> 0;
end;
function GetNotifyIconOverflowWindow: HWND;
begin
Result := FindWindow('NotifyIconOverflowWindow', nil);
end;
function GetTrayNotifyWndToolbar: HWND;
var
Shell_TrayWnd: HWND;
TrayNotifyWnd: HWND;
SysPager: HWND;
ToolbarWindow32: HWND;
begin
Shell_TrayWnd := FindWindow('Shell_TrayWnd', nil);
if Shell_TrayWnd <> 0 then
begin
TrayNotifyWnd := FindWindowEx(Shell_TrayWnd, 0, 'TrayNotifyWnd', nil);
if TrayNotifyWnd <> 0 then
begin
SysPager := FindWindowEx(TrayNotifyWnd, 0, 'SysPager', nil);
if SysPager <> 0 then
begin
// Получение дескриптора окна ToolbarWindow32 содержащего иконки
ToolbarWindow32 := FindWindowEx(SysPager, 0, 'ToolbarWindow32', nil);
if ToolbarWindow32 <> 0 then
Exit(ToolbarWindow32);
end;
// В Windows Vista 2 окна SysPager
SysPager := FindWindowEx(TrayNotifyWnd, SysPager, 'SysPager', nil);
if SysPager <> 0 then
begin
// Получение дескриптора окна ToolbarWindow32 содержащего иконки
ToolbarWindow32 := FindWindowEx(SysPager, 0, 'ToolbarWindow32', nil);
if ToolbarWindow32 <> 0 then
Exit(ToolbarWindow32);
end;
end;
end;
Result := 0;
end;
function GetTaskbarPos: TRect;
var
ABData : TAppBarData;
begin
ABData.cbSize := sizeof(ABData);
if SHAppBarMessage(ABM_GETTASKBARPOS, ABData) > 0 then
Result := ABData.rc
else
Result := TRect.Empty;
end;
function GET_X_LPARAM(const lParam: LPARAM): Integer;
begin
Result := Integer(SHORT(LOWORD(lParam)));
end;
function GET_Y_LPARAM(const lParam: LPARAM): Integer;
begin
Result := Integer(SHORT(HiWord(lParam)));
end;
end.