Commit 9e351472 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shell32: Always set last error in Shell_NotifyIconW.

parent 1cd47755
......@@ -148,7 +148,11 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
}
tray = FindWindowExW(0, NULL, L"Shell_TrayWnd", NULL);
if (!tray) return FALSE;
if (!tray)
{
SetLastError(E_FAIL);
return FALSE;
}
cds.dwData = dwMessage;
cds.cbData = sizeof(*data);
......@@ -185,6 +189,7 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
{
DeleteObject(iconinfo.hbmMask);
if (iconinfo.hbmColor) DeleteObject(iconinfo.hbmColor);
SetLastError(E_OUTOFMEMORY);
return FALSE;
}
......@@ -241,6 +246,7 @@ noicon:
cds.lpData = data;
ret = SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
if (data != &data_buffer) heap_free( data );
SetLastError(ret ? S_OK : E_FAIL);
return ret;
}
......
......@@ -44,8 +44,11 @@ static void test_cbsize(void)
nidW.uFlags = NIF_ICON|NIF_MESSAGE;
nidW.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
nidW.uCallbackMessage = WM_USER+17;
SetLastError(0xdeadbeef);
ret = pShell_NotifyIconW(NIM_ADD, &nidW);
ok(ret, "NIM_ADD failed!\n");
ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_NO_TOKEN,
"GetLastError() = %lu\n", GetLastError());
/* using an invalid cbSize does work */
nidW.cbSize = 3;
nidW.hWnd = hMainWnd;
......@@ -54,7 +57,10 @@ static void test_cbsize(void)
ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
/* as icon doesn't exist anymore - now there will be an error */
nidW.cbSize = sizeof(nidW);
SetLastError(0xdeadbeef);
ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
ok(GetLastError() == E_FAIL || GetLastError() == ERROR_TIMEOUT,
"GetLastError() = %lu\n", GetLastError());
}
/* same for Shell_NotifyIconA */
......@@ -65,7 +71,10 @@ static void test_cbsize(void)
nidA.uFlags = NIF_ICON|NIF_MESSAGE;
nidA.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
nidA.uCallbackMessage = WM_USER+17;
SetLastError(0xdeadbeef);
ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_NO_TOKEN,
"GetLastError() = %lu\n", GetLastError());
/* using an invalid cbSize does work */
nidA.cbSize = 3;
......@@ -75,7 +84,10 @@ static void test_cbsize(void)
ok(ret, "NIM_DELETE failed!\n");
/* as icon doesn't exist anymore - now there will be an error */
nidA.cbSize = sizeof(nidA);
SetLastError(0xdeadbeef);
ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
ok(GetLastError() == E_FAIL || GetLastError() == ERROR_TIMEOUT,
"GetLastError() = %lu\n", GetLastError());
}
START_TEST(systray)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment