Commit d457b37d authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: toolbar: Use correctly wParam in TB_ADDBITMAP.

parent 89f537dd
......@@ -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);
......
......@@ -2625,9 +2625,6 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
else
{
nButtons = (INT)wParam;
if (nButtons <= 0)
return -1;
TRACE ("adding %d bitmaps!\n", nButtons);
}
......@@ -2762,17 +2759,18 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (nIndex != -1)
{
INT imagecount = ImageList_GetImageCount(himlDef);
if (infoPtr->nNumBitmaps + nButtons != imagecount)
INT added = imagecount - nCount;
if (nButtons == 0) /* wParam == 0 is special and means add only one image */
{
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);
infoPtr->nNumBitmaps = imagecount;
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);
}
else
infoPtr->nNumBitmaps += nButtons;
infoPtr->nNumBitmaps += added;
}
InvalidateRect(hwnd, NULL, TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment