diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index c53d726ed1a..ac9019ae53b 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c @@ -882,6 +882,10 @@ UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data) int height=data->rc.bottom - data->rc.top; RECT rec=data->rc; + TRACE("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}\n", + msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge, + wine_dbgstr_rect(&data->rc), data->lParam); + switch (msg) { case ABM_GETSTATE: @@ -894,8 +898,7 @@ UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data) SetActiveWindow(data->hWnd); return TRUE; case ABM_GETAUTOHIDEBAR: - data->hWnd=GetActiveWindow(); - return TRUE; + return 0; /* pretend there is no autohide bar */ case ABM_NEW: /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */ SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE); diff --git a/dlls/shell32/tests/systray.c b/dlls/shell32/tests/systray.c index 23e1ba3fc5e..f1cd62bba01 100644 --- a/dlls/shell32/tests/systray.c +++ b/dlls/shell32/tests/systray.c @@ -75,6 +75,40 @@ void test_cbsize(void) ok(!Shell_NotifyIconA(NIM_DELETE, &nidA), "The icon was not deleted\n"); } +static void test_SHAppBarMessage(void) +{ + APPBARDATA abd; + HWND hwnd, foregnd; + + memset(&abd, 0xcc, sizeof(abd)); + abd.cbSize = sizeof(abd); + abd.uEdge = ABE_BOTTOM; + + hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd); + ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd); + ok(abd.hWnd == (HWND)0xcccccccc, "hWnd overwritten\n"); + + /* Presumably one can pass a hwnd with ABM_GETAUTOHIDEBAR to specify a monitor. + Pass the foreground window and check */ + foregnd = GetForegroundWindow(); + if(foregnd) + { + abd.hWnd = foregnd; + hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd); + ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd); + ok(abd.hWnd == foregnd, "hWnd overwritten\n"); + if(hwnd) + { + HMONITOR appbar_mon, foregnd_mon; + appbar_mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + foregnd_mon = MonitorFromWindow(foregnd, MONITOR_DEFAULTTONEAREST); + ok(appbar_mon == foregnd_mon, "Windows on different monitors\n"); + } + } + + return; +} + START_TEST(systray) { WNDCLASSA wc; @@ -110,4 +144,6 @@ START_TEST(systray) DispatchMessageA(&msg); } DestroyWindow(hMainWnd); + + test_SHAppBarMessage(); }