shell32: correct SHAppBarMessage ABM_GETTASKBARPOS, ABM_QUERYPOS etc.

Hongbo Ni hongbo at njstar.com
Wed Jul 30 05:38:18 CDT 2008


This patch fixes the crash of ICQ v5.1 calling SHAppBarMessage in Bug # 6078.

Without knowing where is the taskbar, and without a global list of appbars,
this patch make Appbar window working like a normal Topmost window.
---
 dlls/shell32/shell32_main.c |   46 ++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index 3026582..111b3de 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -871,49 +871,57 @@ static void paint_dropline( HDC hdc, HWND hWnd )
  */
 UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
 {
-    int width=data->rc.right - data->rc.left;
-    int height=data->rc.bottom - data->rc.top;
-    RECT rec=data->rc;
+    RECT rec;

     FIXME("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}: stub\n",
           msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge,
           wine_dbgstr_rect(&data->rc), data->lParam);

+    /* FIXME: create a global appbar list and autohide list - in winserver ? */
+
     switch (msg)
     {
     case ABM_GETSTATE:
         return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
     case ABM_GETTASKBARPOS:
-        /* FIXME: This is wrong.  It should return the taskbar co-ords and edge from the monitor
-           which contains data->hWnd */
-        GetWindowRect(data->hWnd, &rec);
-        data->rc=rec;
+        data->rc.top = data->rc.left = 0;
+        data->rc.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
+        data->rc.right = GetSystemMetrics(SM_CXFULLSCREEN);
+        SystemParametersInfoW(SPI_GETWORKAREA, 0, &rec, 0);
+        if(rec.top > 0)  /* docked at top */
+            data->rc.bottom = rec.top - 1;
+        else if(rec.left > 0)  /* docked at left */
+            data->rc.right = rec.right - 1;
+        else if(rec.right < data->rc.right)  /* docked at right */
+            data->rc.left = rec.left + 1;
+        else  /* docked at bottom */
+            data->rc.top = rec.bottom + 1;
         return TRUE;
     case ABM_ACTIVATE:
-        SetActiveWindow(data->hWnd);
         return TRUE;
     case ABM_GETAUTOHIDEBAR:
+        /* FIXME: return autohide bar on data->uEdge */
         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);
+        /* FIXME: add this hWnd to the global appbar list, record uCallbackMessage */
         return TRUE;
     case ABM_QUERYPOS:
-        GetWindowRect(data->hWnd, &(data->rc));
+        /* adjust rc so that the appbar does not go out of work area */
+        SystemParametersInfoW(SPI_GETWORKAREA, 0, &rec, 0);
+        if(data->rc.top < rec.top) data->rc.top = rec.top;
+        if(data->rc.left < rec.left) data->rc.left = rec.left;
+        if(data->rc.right > rec.right) data->rc.right = rec.right;
+        if(data->rc.bottom > rec.bottom) data->rc.bottom = rec.bottom;
         return TRUE;
     case ABM_REMOVE:
-        FIXME("ABM_REMOVE broken\n");
-        /* FIXME: this is wrong; should it be DestroyWindow instead? */
-        /*CloseHandle(data->hWnd);*/
+        /* FIXME: remove this bar from appbar list and autohide list */
         return TRUE;
     case ABM_SETAUTOHIDEBAR:
-        SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
-                         width,height,SWP_SHOWWINDOW);
+        /* FIXME: if(data->lParam): set this bar to autohide on uEdge */
+        /* FIXME: else: unset this bar from autohide on uEdge */
         return TRUE;
     case ABM_SETPOS:
-        data->uEdge=(ABE_RIGHT | ABE_LEFT);
-        SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
-                     width,height,SWP_SHOWWINDOW);
+        /* FIXME: send the ABN_POSCHANGED notification to all appbars */
         return TRUE;
     case ABM_WINDOWPOSCHANGED:
         return TRUE;
--
1.5.6.1.1071.g76fb





More information about the wine-patches mailing list