1 /* Unit tests for systray
3 * Copyright 2007 Mikolaj Zalewski
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define _WIN32_IE 0x600
24 #include "wine/test.h"
28 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
30 static void test_cbsize(void)
35 if (pShell_NotifyIconW)
39 ZeroMemory(&nidW, sizeof(nidW));
40 nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
43 nidW.uFlags = NIF_ICON|NIF_MESSAGE;
44 nidW.hIcon = LoadIcon(NULL, IDI_APPLICATION);
45 nidW.uCallbackMessage = WM_USER+17;
46 ret = pShell_NotifyIconW(NIM_ADD, &nidW);
47 /* using an invalid cbSize does work */
51 ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
52 ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
53 /* as icon doesn't exist anymore - now there will be an error */
54 nidW.cbSize = sizeof(nidW);
55 ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
58 /* same for Shell_NotifyIconA */
59 ZeroMemory(&nidA, sizeof(nidA));
60 nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
63 nidA.uFlags = NIF_ICON|NIF_MESSAGE;
64 nidA.hIcon = LoadIcon(NULL, IDI_APPLICATION);
65 nidA.uCallbackMessage = WM_USER+17;
66 ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
68 /* using an invalid cbSize does work */
72 ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
73 ok(ret, "NIM_DELETE failed!\n");
74 /* as icon doesn't exist anymore - now there will be an error */
75 nidA.cbSize = sizeof(nidA);
76 ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
86 hshell32 = GetModuleHandleA("shell32.dll");
87 pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
89 wc.style = CS_HREDRAW | CS_VREDRAW;
92 wc.hInstance = GetModuleHandleA(NULL);
94 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
95 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
96 wc.lpszMenuName = NULL;
97 wc.lpszClassName = "MyTestWnd";
98 wc.lpfnWndProc = DefWindowProc;
101 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
102 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
103 GetClientRect(hMainWnd, &rc);
104 ShowWindow(hMainWnd, SW_SHOW);
109 while(GetMessageA(&msg,0,0,0)) {
110 TranslateMessage(&msg);
111 DispatchMessageA(&msg);
113 DestroyWindow(hMainWnd);