TB_ReplaceBitmaps fix.

Rein Klazes rklazes at xs4all.nl
Fri Nov 21 05:35:00 CST 2003


Hi,

Fix for Agent 2.0 beta.

Changelog:
	dlls/comctl32	: toolbar.c
	Fix some confusion between number of bitmaps and number of 
	buttons in TOOLBAR_ReplaceBitmap().

Rein.
-- 
Rein Klazes
rklazes at xs4all.nl
-------------- next part --------------
--- wine/dlls/comctl32/toolbar.c	2003-11-21 12:07:15.000000000 +0100
+++ mywine/dlls/comctl32/toolbar.c	2003-11-21 12:22:37.000000000 +0100
@@ -3801,7 +3801,8 @@
     return TRUE;
 }
 
-
+/* FIXME: there might still be some confusion her between number of buttons
+ * and number of bitmaps */
 static LRESULT
 TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
@@ -3809,6 +3810,7 @@
     LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam;
     HBITMAP hBitmap;
     int i = 0, nOldButtons = 0, pos = 0;
+    int nOldBitmaps, nNewBitmaps;
     HIMAGELIST himlDef = 0;
 
     TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
@@ -3852,16 +3854,14 @@
         WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
         return FALSE;
     }
-
-    infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
+    
+    himlDef = GETDEFIMAGELIST(infoPtr, 0); /* fixme: correct? */
+    nOldBitmaps = ImageList_GetImageCount(himlDef);
 
     /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
 
-
-    himlDef = GETDEFIMAGELIST(infoPtr, 0);
-    for (i = pos + nOldButtons - 1; i >= pos; i--) {
+    for (i = pos + nOldBitmaps - 1; i >= pos; i--)
         ImageList_Remove(himlDef, i);
-    }
 
     {
        BITMAP  bmp;
@@ -3891,9 +3891,15 @@
        DeleteDC (hdcBitmap);
 
        ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
+       nNewBitmaps = ImageList_GetImageCount(himlDef);
        DeleteObject (hbmLoad);
     }
 
+    infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldBitmaps + nNewBitmaps;
+
+    TRACE(" pos %d  %d old bitmaps replaced by %d new ones.\n",
+            pos, nOldBitmaps, nNewBitmaps);
+
     InvalidateRect(hwnd, NULL, FALSE);
 
     return TRUE;


More information about the wine-patches mailing list