comctl32: toolbar: TB_SETBITMAPSIZE should not change a coordinate when passed -1 (with testcase).
This commit is contained in:
parent
412cd04cfc
commit
a289bab122
|
@ -203,6 +203,13 @@ static void rebuild_toolbar_with_buttons(HWND *hToolbar)
|
|||
ok(SendMessage(*hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
|
||||
}
|
||||
|
||||
static void add_128x15_bitmap(HWND hToolbar, int nCmds)
|
||||
{
|
||||
TBADDBITMAP bmp128;
|
||||
bmp128.hInst = GetModuleHandle(NULL);
|
||||
bmp128.nID = IDB_BITMAP_128x15;
|
||||
ok(SendMessageA(hToolbar, TB_ADDBITMAP, nCmds, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
|
||||
}
|
||||
|
||||
#define CHECK_IMAGELIST(count, dx, dy) { \
|
||||
int cx, cy; \
|
||||
|
@ -854,6 +861,18 @@ static void test_sizes(void)
|
|||
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(23, 22), "Unexpected button size\n");
|
||||
SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(16, 15));
|
||||
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(23, 21), "Unexpected button size\n");
|
||||
/* -1 in TB_SETBITMAPSIZE is a special code meaning that the coordinate shouldn't be changed */
|
||||
add_128x15_bitmap(hToolbar, 16);
|
||||
ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(14, -1)), "TB_SETBITMAPSIZE failed\n");
|
||||
compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 21), "%x");
|
||||
ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(-1, 12)), "TB_SETBITMAPSIZE failed\n");
|
||||
compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 18), "%x");
|
||||
ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(-1, -1)), "TB_SETBITMAPSIZE failed\n");
|
||||
compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 18), "%x");
|
||||
/* check the imagelist */
|
||||
InvalidateRect(hToolbar, NULL, TRUE);
|
||||
UpdateWindow(hToolbar);
|
||||
CHECK_IMAGELIST(16, 14, 12);
|
||||
|
||||
rebuild_toolbar(&hToolbar);
|
||||
SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"A\0MMMMMMMMMMMMM\0");
|
||||
|
|
|
@ -4374,26 +4374,38 @@ TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
||||
HIMAGELIST himlDef = GETDEFIMAGELIST(infoPtr, 0);
|
||||
short width = (short)LOWORD(lParam);
|
||||
short height = (short)HIWORD(lParam);
|
||||
|
||||
TRACE("hwnd=%p, wParam=%ld, lParam=%ld\n", hwnd, wParam, lParam);
|
||||
|
||||
if (wParam != 0)
|
||||
FIXME("wParam is %ld. Perhaps image list index?\n", wParam);
|
||||
|
||||
if (LOWORD(lParam) == 0)
|
||||
lParam = MAKELPARAM(1, HIWORD(lParam));
|
||||
|
||||
if (HIWORD(lParam)==0)
|
||||
lParam = MAKELPARAM(LOWORD(lParam), 1);
|
||||
/* 0 width or height is changed to 1 */
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
if (infoPtr->nNumButtons > 0)
|
||||
WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
|
||||
infoPtr->nNumButtons,
|
||||
infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
||||
LOWORD(lParam), HIWORD(lParam));
|
||||
TRACE("%d buttons, undoc change to bitmap size : %d-%d -> %d-%d\n",
|
||||
infoPtr->nNumButtons,
|
||||
infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, width, height);
|
||||
|
||||
infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
||||
infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
||||
if (width < -1 || height < -1)
|
||||
{
|
||||
/* Windows destroys the imagelist and seems to actually use negative
|
||||
* values to compute button sizes */
|
||||
FIXME("Negative bitmap sizes not supported (%d, %d)\n", width, height);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* width or height of -1 means no change */
|
||||
if (width != -1)
|
||||
infoPtr->nBitmapWidth = width;
|
||||
if (height != -1)
|
||||
infoPtr->nBitmapHeight = height;
|
||||
|
||||
if ((himlDef == infoPtr->himlInt) &&
|
||||
(ImageList_GetImageCount(infoPtr->himlInt) == 0))
|
||||
|
|
Loading…
Reference in New Issue