Mikołaj Zalewski : comctl32: header: Copy some fields on INSERTITEM even if they are not in the mask.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue May 16 13:54:26 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: bf346b240d2954aa4da208e2e4871fc38d3b9774
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=bf346b240d2954aa4da208e2e4871fc38d3b9774
Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date: Tue May 16 00:05:28 2006 +0200
comctl32: header: Copy some fields on INSERTITEM even if they are not in the mask.
---
dlls/comctl32/header.c | 21 +++++++++-------
dlls/comctl32/tests/header.c | 54 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c
index b91524e..dc533e1 100644
--- a/dlls/comctl32/header.c
+++ b/dlls/comctl32/header.c
@@ -114,21 +114,21 @@ static void HEADER_DisposeItem(HEADER_IT
}
}
-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(H
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
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
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, L
}
lpItem = &infoPtr->items[nItem];
- HEADER_StoreHDItemInHeader(lpItem, phdi, bUnicode);
+ HEADER_StoreHDItemInHeader(lpItem, phdi->mask, phdi, bUnicode);
if (phdi->mask & HDI_ORDER)
{
diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c
index 7e0fda7..856bfc6 100644
--- a/dlls/comctl32/tests/header.c
+++ b/dlls/comctl32/tests/header.c
@@ -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);
More information about the wine-cvs
mailing list