mirror of
https://github.com/reactos/wine.git
synced 2025-02-02 18:25:19 +00:00
comctl32: header: Copy some fields on INSERTITEM even if they are not in the mask.
This commit is contained in:
parent
3eccdfcca7
commit
bf346b240d
@ -114,21 +114,21 @@ static void HEADER_DisposeItem(HEADER_ITEM *lpItem)
|
||||
}
|
||||
}
|
||||
|
||||
static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, HDITEMW *phdi, BOOL fUnicode)
|
||||
static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, HDITEMW *phdi, BOOL fUnicode)
|
||||
{
|
||||
if (phdi->mask & HDI_BITMAP)
|
||||
if (mask & HDI_BITMAP)
|
||||
lpItem->hbm = phdi->hbm;
|
||||
|
||||
if (phdi->mask & HDI_FORMAT)
|
||||
if (mask & HDI_FORMAT)
|
||||
lpItem->fmt = phdi->fmt;
|
||||
|
||||
if (phdi->mask & HDI_LPARAM)
|
||||
if (mask & HDI_LPARAM)
|
||||
lpItem->lParam = phdi->lParam;
|
||||
|
||||
if (phdi->mask & HDI_WIDTH)
|
||||
if (mask & HDI_WIDTH)
|
||||
lpItem->cxy = phdi->cxy;
|
||||
|
||||
if (phdi->mask & HDI_IMAGE)
|
||||
if (mask & HDI_IMAGE)
|
||||
{
|
||||
lpItem->iImage = phdi->iImage;
|
||||
if (phdi->iImage == I_IMAGECALLBACK)
|
||||
@ -137,7 +137,7 @@ static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, HDITEMW *phdi, BOOL
|
||||
lpItem->callbackMask &= ~HDI_IMAGE;
|
||||
}
|
||||
|
||||
if (phdi->mask & HDI_TEXT)
|
||||
if (mask & HDI_TEXT)
|
||||
{
|
||||
if (lpItem->pszText)
|
||||
{
|
||||
@ -1092,6 +1092,7 @@ HEADER_InsertItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
|
||||
HEADER_ITEM *lpItem;
|
||||
INT iOrder;
|
||||
UINT i;
|
||||
UINT copyMask;
|
||||
|
||||
if ((phdi == NULL) || (nItem < 0))
|
||||
return -1;
|
||||
@ -1154,7 +1155,9 @@ HEADER_InsertItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
|
||||
|
||||
lpItem = &infoPtr->items[nItem];
|
||||
ZeroMemory(lpItem, sizeof(HEADER_ITEM));
|
||||
HEADER_StoreHDItemInHeader(lpItem, phdi, bUnicode);
|
||||
/* cxy, fmt and lParam are copied even if not in the HDITEM mask */
|
||||
copyMask = phdi->mask | HDI_WIDTH | HDI_FORMAT | HDI_LPARAM;
|
||||
HEADER_StoreHDItemInHeader(lpItem, copyMask, phdi, bUnicode);
|
||||
|
||||
/* set automatically some format bits */
|
||||
if (phdi->mask & HDI_TEXT)
|
||||
@ -1267,7 +1270,7 @@ HEADER_SetItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
|
||||
}
|
||||
|
||||
lpItem = &infoPtr->items[nItem];
|
||||
HEADER_StoreHDItemInHeader(lpItem, phdi, bUnicode);
|
||||
HEADER_StoreHDItemInHeader(lpItem, phdi->mask, phdi, bUnicode);
|
||||
|
||||
if (phdi->mask & HDI_ORDER)
|
||||
{
|
||||
|
@ -269,6 +269,58 @@ static void check_auto_format(void)
|
||||
ok(hdiRead.fmt == (HDF_CENTER|HDF_IMAGE), "HDF_IMAGE shouldn't be cleared automatically (fmt=%x)\n", hdiRead.fmt);
|
||||
}
|
||||
|
||||
static void check_auto_fields(void)
|
||||
{
|
||||
HDITEMA hdiCreate;
|
||||
HDITEMA hdiRead;
|
||||
LRESULT res;
|
||||
|
||||
/* Windows stores the format, width, lparam even if they are not in the item's mask */
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.cxy = 100;
|
||||
hdiCreate.pszText = "Test";
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_WIDTH, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.cxy == hdiCreate.cxy, "cxy should be automatically set\n");
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = "Test";
|
||||
hdiCreate.lParam = 0x12345678;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_LPARAM, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.lParam == hdiCreate.lParam, "lParam should be automatically set\n");
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = "Test";
|
||||
hdiCreate.fmt = HDF_STRING|HDF_CENTER;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.fmt == hdiCreate.fmt, "fmt should be automatically set\n");
|
||||
|
||||
/* others fields are not set */
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = "Test";
|
||||
hdiCreate.hbm = CreateBitmap(16, 16, 1, 8, NULL);
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_BITMAP, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.hbm == NULL, "hbm should not be automatically set\n");
|
||||
DeleteObject(hdiCreate.hbm);
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_IMAGE;
|
||||
hdiCreate.iImage = 17;
|
||||
hdiCreate.pszText = "Test";
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_TEXT, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.pszText==NULL, "pszText shouldn't be automatically set\n");
|
||||
|
||||
/* field from comctl >4.0 not tested as the system probably won't touch them */
|
||||
}
|
||||
|
||||
static void test_header_control (void)
|
||||
{
|
||||
LONG res;
|
||||
@ -342,6 +394,8 @@ static void test_header_control (void)
|
||||
|
||||
check_auto_format();
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
check_auto_fields();
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
|
||||
res = delItem(hWndHeader, 5);
|
||||
ok(res == 1, "Deleting Out of Range item should fail with 1 (%ld)\n", res);
|
||||
|
Loading…
x
Reference in New Issue
Block a user