From 7f7cde0eee14e34ecb0593b545560ad210734ae3 Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Fri, 21 Nov 2003 21:30:48 +0000 Subject: [PATCH] Fix some confusion between number of bitmaps and number of buttons in TOOLBAR_ReplaceBitmap(). --- dlls/comctl32/toolbar.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index e8ec1f850e9..1fdacc4c4ec 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -3801,7 +3801,8 @@ TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam) 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 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) 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 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) 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 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) 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;