comctl32: A change in TBSTYLE_WRAPABLE should produce a recalc.

This commit is contained in:
Huw Davies 2015-04-28 11:32:01 +01:00 committed by Alexandre Julliard
parent e82b9dc32e
commit abd673bde9
2 changed files with 47 additions and 3 deletions

View File

@ -1388,12 +1388,12 @@ static void restore_recalc_state(HWND hToolbar)
RECT rect; RECT rect;
/* return to style with a 2px top margin */ /* return to style with a 2px top margin */
SetWindowLongA(hToolbar, GWL_STYLE, SetWindowLongA(hToolbar, GWL_STYLE,
GetWindowLongA(hToolbar, GWL_STYLE) & ~TBSTYLE_FLAT); SendMessageA(hToolbar, TB_GETSTYLE, 0, 0) & ~TBSTYLE_FLAT);
/* recalc */ /* recalc */
SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&buttons3[3]); SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&buttons3[3]);
/* top margin will be 0px if a recalc occurs */ /* top margin will be 0px if a recalc occurs */
SetWindowLongA(hToolbar, GWL_STYLE, SetWindowLongA(hToolbar, GWL_STYLE,
GetWindowLongA(hToolbar, GWL_STYLE) | TBSTYLE_FLAT); SendMessageA(hToolbar, TB_GETSTYLE, 0, 0) | TBSTYLE_FLAT);
/* safety check */ /* safety check */
SendMessageA(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect); SendMessageA(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n", ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n",
@ -1408,6 +1408,7 @@ static void test_recalc(void)
const int EX_STYLES_COUNT = 5; const int EX_STYLES_COUNT = 5;
int i; int i;
BOOL recalc; BOOL recalc;
DWORD style;
/* Like TB_ADDBUTTONSA tested in test_sized, inserting a button without text /* Like TB_ADDBUTTONSA tested in test_sized, inserting a button without text
* results in a relayout, while adding one with text forces a recalc */ * results in a relayout, while adding one with text forces a recalc */
@ -1468,6 +1469,47 @@ static void test_recalc(void)
/* undocumented exstyle 0x2 seems to change the top margin, which /* undocumented exstyle 0x2 seems to change the top margin, which
* interferes with these tests */ * interferes with these tests */
/* Show that a change in TBSTYLE_WRAPABLE causes a recalc */
prepare_recalc_test(&hToolbar);
style = SendMessageA(hToolbar, TB_GETSTYLE, 0, 0);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style);
recalc = did_recalc(hToolbar);
ok(!recalc, "recalc %d\n", recalc);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | CCS_BOTTOM);
recalc = did_recalc(hToolbar);
ok(!recalc, "recalc %d\n", recalc);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_WRAPABLE);
recalc = did_recalc(hToolbar);
ok(recalc, "recalc %d\n", recalc);
restore_recalc_state(hToolbar);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_WRAPABLE);
recalc = did_recalc(hToolbar);
ok(!recalc, "recalc %d\n", recalc);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style);
recalc = did_recalc(hToolbar);
ok(recalc, "recalc %d\n", recalc);
restore_recalc_state(hToolbar);
/* Changing CCS_VERT does not recalc */
SendMessageA(hToolbar, TB_SETSTYLE, 0, style | CCS_VERT);
recalc = did_recalc(hToolbar);
ok(!recalc, "recalc %d\n", recalc);
restore_recalc_state(hToolbar);
SendMessageA(hToolbar, TB_SETSTYLE, 0, style);
recalc = did_recalc(hToolbar);
ok(!recalc, "recalc %d\n", recalc);
restore_recalc_state(hToolbar);
/* Setting the window's style directly also causes recalc */
SetWindowLongA(hToolbar, GWL_STYLE, style | TBSTYLE_WRAPABLE);
recalc = did_recalc(hToolbar);
ok(recalc, "recalc %d\n", recalc);
DestroyWindow(hToolbar); DestroyWindow(hToolbar);
} }

View File

@ -4934,7 +4934,9 @@ TOOLBAR_SetStyle (TOOLBAR_INFO *infoPtr, DWORD style)
infoPtr->dwStyle = style; infoPtr->dwStyle = style;
TOOLBAR_CheckStyle(infoPtr); TOOLBAR_CheckStyle(infoPtr);
if ((dwOldStyle ^ style) & (TBSTYLE_WRAPABLE | CCS_VERT)) if ((dwOldStyle ^ style) & TBSTYLE_WRAPABLE)
TOOLBAR_CalcToolbar(infoPtr);
else if ((dwOldStyle ^ style) & CCS_VERT)
TOOLBAR_LayoutToolbar(infoPtr); TOOLBAR_LayoutToolbar(infoPtr);
/* only resize if one of the CCS_* styles was changed */ /* only resize if one of the CCS_* styles was changed */