Commit 7f7cde0e authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

Fix some confusion between number of bitmaps and number of buttons in

TOOLBAR_ReplaceBitmap().
parent 4a8e3395
...@@ -3801,7 +3801,8 @@ TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3801,7 +3801,8 @@ TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} }
/* FIXME: there might still be some confusion her between number of buttons
* and number of bitmaps */
static LRESULT static LRESULT
TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
...@@ -3809,6 +3810,7 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3809,6 +3810,7 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam; LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam;
HBITMAP hBitmap; HBITMAP hBitmap;
int i = 0, nOldButtons = 0, pos = 0; int i = 0, nOldButtons = 0, pos = 0;
int nOldBitmaps, nNewBitmaps;
HIMAGELIST himlDef = 0; HIMAGELIST himlDef = 0;
TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n", TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
...@@ -3853,15 +3855,13 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3853,15 +3855,13 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
return FALSE; 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); */ /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
for (i = pos + nOldBitmaps - 1; i >= pos; i--)
himlDef = GETDEFIMAGELIST(infoPtr, 0);
for (i = pos + nOldButtons - 1; i >= pos; i--) {
ImageList_Remove(himlDef, i); ImageList_Remove(himlDef, i);
}
{ {
BITMAP bmp; BITMAP bmp;
...@@ -3891,9 +3891,15 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3891,9 +3891,15 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT); ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
nNewBitmaps = ImageList_GetImageCount(himlDef);
DeleteObject (hbmLoad); 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); InvalidateRect(hwnd, NULL, FALSE);
return TRUE; return 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