Mikołaj Zalewski : comctl32: toolbar: Use correctly wParam in TB_ADDBITMAP.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 25 09:46:47 CDT 2006


Module: wine
Branch: master
Commit: d457b37d822323ddd82d66d6315a7be4c8ce61a7
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=d457b37d822323ddd82d66d6315a7be4c8ce61a7

Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date:   Wed Sep 20 17:44:36 2006 +0200

comctl32: toolbar: Use correctly wParam in TB_ADDBITMAP.

---

 dlls/comctl32/tests/toolbar.c |   16 ++++++++--------
 dlls/comctl32/toolbar.c       |   26 ++++++++++++--------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 699b4a7..bfcbd67 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -194,25 +194,25 @@ static void test_add_bitmap(void)
     /* the same for negative wParam */
     rebuild_toolbar(&hToolbar);
     ret = SendMessageA(hToolbar, TB_ADDBITMAP, -143, (LPARAM)&bmp128);
-    todo_wine ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
-    todo_wine CHECK_IMAGELIST(8, 16, 15);
+    ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
+    CHECK_IMAGELIST(8, 16, 15);
     ret = SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp80);
     todo_wine ok(ret == -143, "TB_ADDBITMAP - unexpected return %d\n", ret);
-    CHECK_IMAGELIST_TODO_COUNT(13, 16, 15);
+    CHECK_IMAGELIST(13, 16, 15);
 
     /* for zero only one bitmap will be added */
     rebuild_toolbar(&hToolbar);
     ret = SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&bmp80);
-    todo_wine ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
-    todo_wine CHECK_IMAGELIST(1, 16, 15);
+    ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
+    CHECK_IMAGELIST(1, 16, 15);
 
     /* if wParam is larger than the amount of icons, the list is grown */
     rebuild_toolbar(&hToolbar);
     ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp80) == 0, "TB_ADDBITMAP - unexpected return\n");
-    CHECK_IMAGELIST_TODO_COUNT(100, 16, 15);
+    CHECK_IMAGELIST(100, 16, 15);
     ret = SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp128);
-    todo_wine ok(ret == 100, "TB_ADDBITMAP - unexpected return %d\n", ret);
-    CHECK_IMAGELIST_TODO_COUNT(200, 16, 15);
+    ok(ret == 100, "TB_ADDBITMAP - unexpected return %d\n", ret);
+    CHECK_IMAGELIST(200, 16, 15);
 
     /* adding built-in items - the wParam is ignored */
     rebuild_toolbar(&hToolbar);
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 9a04ecf..840a08a 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -2625,9 +2625,6 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wPa
     else
     {
 	nButtons = (INT)wParam;
-	if (nButtons <= 0)
-	    return -1;
-
 	TRACE ("adding %d bitmaps!\n", nButtons);
     }
 
@@ -2761,18 +2758,19 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wPa
 
     if (nIndex != -1)
     {
-       INT imagecount = ImageList_GetImageCount(himlDef);
-
-       if (infoPtr->nNumBitmaps + nButtons != imagecount)
-       {
-         WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
-	      infoPtr->nNumBitmaps, nCount, imagecount - nCount,
-	      infoPtr->nNumBitmaps+nButtons,imagecount);
+        INT imagecount = ImageList_GetImageCount(himlDef);
+        INT added =  imagecount - nCount;
+        if (nButtons == 0) /* wParam == 0 is special and means add only one image */
+        {
+            ImageList_SetImageCount(himlDef, nCount + 1);
+        } else if (added < nButtons) {    /* if not enough buttons, grow the list */
+            ImageList_SetImageCount(himlDef, nCount + nButtons);
+        } else if (added > nButtons) {
+            TRACE("Added more images than wParam: Previous image number %i added %i while nButtons %i. Images in list %i\n",
+                nCount, added, nButtons, imagecount);
+        }
 
-	 infoPtr->nNumBitmaps = imagecount;
-       }
-       else
-         infoPtr->nNumBitmaps += nButtons;
+        infoPtr->nNumBitmaps += added;
     }
 
     InvalidateRect(hwnd, NULL, TRUE);




More information about the wine-cvs mailing list