reshuffling of dlls
[reactos.git] / reactos / dll / win32 / shell32 / ros-systray.c
1 /*
2 * Copyright 2004 Martin Fuchs
3 *
4 * Pass on icon notification messages to the systray implementation
5 * in the currently running shell.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 #include <stdarg.h>
23 #include <malloc.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "shellapi.h"
29
30
31 /* copy data structure for tray notifications */
32 typedef struct TrayNotifyCDS_Dummy {
33 DWORD cookie;
34 DWORD notify_code;
35 DWORD nicon_data[1]; // placeholder for NOTIFYICONDATA structure
36 } TrayNotifyCDS_Dummy;
37
38 /* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */
39 static BOOL SHELL_NotifyIcon(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode)
40 {
41 HWND hwnd;
42 COPYDATASTRUCT data;
43
44 BOOL ret = FALSE;
45 int len = sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+nid_size;
46
47 TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len);
48
49 pnotify_data->cookie = 1;
50 pnotify_data->notify_code = dwMessage;
51 memcpy(&pnotify_data->nicon_data, pnid, nid_size);
52
53 data.dwData = 1;
54 data.cbData = len;
55 data.lpData = pnotify_data;
56
57 for(hwnd=0; (hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL)); )
58 if ((unicode?SendMessageW:SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data))
59 ret = TRUE;
60
61 return ret;
62 }
63
64
65 /*************************************************************************
66 * Shell_NotifyIcon [SHELL32.296]
67 * Shell_NotifyIconA [SHELL32.297]
68 */
69 BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
70 {
71 return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
72 }
73
74 /*************************************************************************
75 * Shell_NotifyIconW [SHELL32.298]
76 */
77 BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
78 {
79 return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, TRUE);
80 }