comctl32: toolbar: fix the TB_SETBITMAPSIZE for width or height zero (with testcase)

Mikołaj Zalewski mikolaj at zalewski.pl
Tue Jan 16 08:41:44 CST 2007


  Tests and a glitch in an application shows that the previous behaviour 
was wrong.
-------------- next part --------------
From 193f1359908fa8a996063481923c8f29bfee0eef Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Tue, 16 Jan 2007 15:38:19 +0100
Subject: [PATCH] comctl32: toolbar: fix the TB_SETBITMAPSIZE for width or height zero (with testcase)

---
 dlls/comctl32/tests/toolbar.c |   10 ++++++++++
 dlls/comctl32/toolbar.c       |    7 +++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index f1f3187..164644e 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -330,6 +330,16 @@ static void test_add_bitmap(void)
     ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(30, 30)) == TRUE, "TB_SETBITMAPSIZE failed\n");
     UpdateWindow(hToolbar);
     CHECK_IMAGELIST(8, 30, 30);
+    /* when the width or height is zero, set it to 1 */
+    ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0, 0)) == TRUE, "TB_SETBITMAPSIZE failed\n");
+    UpdateWindow(hToolbar);
+    CHECK_IMAGELIST(208, 1, 1);
+    ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0, 5)) == TRUE, "TB_SETBITMAPSIZE failed\n");
+    UpdateWindow(hToolbar);
+    CHECK_IMAGELIST(208, 1, 5);
+    ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(5, 0)) == TRUE, "TB_SETBITMAPSIZE failed\n");
+    UpdateWindow(hToolbar);
+    CHECK_IMAGELIST(41, 5, 1);
 
     /* the control can add bitmaps to an existing image list */
     rebuild_toolbar(&hToolbar);
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 85ada79..b90a36c 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -4489,8 +4489,11 @@ TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
     if (wParam != 0)
         FIXME("wParam is %d. Perhaps image list index?\n", wParam);
 
-    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
-        lParam = MAKELPARAM(16, 15);
+    if (LOWORD(lParam) == 0)
+        lParam = MAKELPARAM(1, HIWORD(lParam));
+        
+    if (HIWORD(lParam)==0)
+        lParam = MAKELPARAM(LOWORD(lParam), 1);
 
     if (infoPtr->nNumButtons > 0)
         WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
-- 
1.4.4.2


More information about the wine-patches mailing list