Igor Tarasov : comctl32: TOOLBAR_SetImageList should recalculate toolbar only if it is necessary.
Alexandre Julliard
julliard at winehq.org
Wed Apr 22 10:18:48 CDT 2009
Module: wine
Branch: master
Commit: 3e235cc3632ee92cf4d02be695a194ff357e1ce7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3e235cc3632ee92cf4d02be695a194ff357e1ce7
Author: Igor Tarasov <tarasov.igor at gmail.com>
Date: Wed Apr 22 05:15:16 2009 +0500
comctl32: TOOLBAR_SetImageList should recalculate toolbar only if it is necessary.
---
dlls/comctl32/tests/toolbar.c | 8 ++++++--
dlls/comctl32/toolbar.c | 11 ++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 0c560b1..1946095 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -777,7 +777,7 @@ static TBBUTTON buttons3[] = {
static void test_sizes(void)
{
HWND hToolbar = NULL;
- HIMAGELIST himl;
+ HIMAGELIST himl, himl2;
TBBUTTONINFO tbinfo;
int style;
int i;
@@ -928,9 +928,13 @@ static void test_sizes(void)
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 21), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 100), "Unexpected button size\n");
+ /* But there are no update when we change imagelist, and image sizes are the same */
+ himl2 = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_128x15), 20, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
+ ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LRESULT)himl2) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
+ ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 100), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(27, 21), "Unexpected button size\n");
- ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
+ ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl2, "TB_SETIMAGELIST failed\n");
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(27, 7), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(8, 7), "Unexpected button size\n");
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index cf54df7..1ba284c 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -4777,6 +4777,8 @@ TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
HIMAGELIST himlTemp;
HIMAGELIST himl = (HIMAGELIST)lParam;
INT oldButtonWidth = infoPtr->nButtonWidth;
+ INT oldBitmapWidth = infoPtr->nBitmapWidth;
+ INT oldBitmapHeight = infoPtr->nBitmapHeight;
INT i, id = 0;
if (infoPtr->iVersion >= 5)
@@ -4795,9 +4797,12 @@ TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->nBitmapWidth = 1;
infoPtr->nBitmapHeight = 1;
}
- TOOLBAR_CalcToolbar(hwnd);
- if (infoPtr->nButtonWidth < oldButtonWidth)
- TOOLBAR_SetButtonSize(hwnd, MAKELONG(oldButtonWidth, infoPtr->nButtonHeight));
+ if ((oldBitmapWidth != infoPtr->nBitmapWidth) || (oldBitmapHeight != infoPtr->nBitmapHeight))
+ {
+ TOOLBAR_CalcToolbar(hwnd);
+ if (infoPtr->nButtonWidth < oldButtonWidth)
+ TOOLBAR_SetButtonSize(hwnd, MAKELONG(oldButtonWidth, infoPtr->nButtonHeight));
+ }
TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
hwnd, infoPtr->himlDef, id, infoPtr->nNumBitmaps,
More information about the wine-cvs
mailing list