From 740e7be12883eed4c7cc7e65c1ab641da33476ca Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 6 May 2011 12:48:14 +0400 Subject: [PATCH] comctl32/listview: Don't refuse to set subitem data when some extra flag is specified. --- dlls/comctl32/listview.c | 4 ++-- dlls/comctl32/tests/listview.c | 54 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 1f64cbeebdd..9f8b2a9048d 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -4272,9 +4272,9 @@ static BOOL set_sub_item(const LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, particularly useful. We currently do not actually do anything with the flag on subitems. */ - if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE | LVIF_STATE)) return FALSE; + if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_DI_SETITEM)) return FALSE; if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE | LVIF_STATE))) return TRUE; - + /* get the subitem structure, and create it if not there */ hdpaSubItems = DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); assert (hdpaSubItems); diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 305ec2d4ef0..e9fa684fd75 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -3,7 +3,7 @@ * * Copyright 2006 Mike McCormack for CodeWeavers * Copyright 2007 George Gov - * Copyright 2009 Nikolay Sivov + * Copyright 2009-2011 Nikolay Sivov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1030,10 +1030,11 @@ static void insert_item(HWND hwnd, int idx) static void test_items(void) { const LPARAM lparamTest = 0x42; + static CHAR text[] = "Text"; + char buffA[5]; HWND hwnd; LVITEMA item; DWORD r; - static CHAR text[] = "Text"; hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT, 10, 10, 100, 200, hwndparent, NULL, NULL, NULL); @@ -1140,6 +1141,55 @@ static void test_items(void) r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item); ok(r == 1, "ret %d\n", r); + item.mask = LVIF_TEXT; + item.iItem = 0; + item.iSubItem = 1; + item.pszText = buffA; + item.cchTextMax = sizeof(buffA); + r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item); + ok(r == 1, "ret %d\n", r); + ok(!memcmp(item.pszText, text, sizeof(text)), "got text %s, expected %s\n", item.pszText, text); + + /* set up with extra flag */ + /* 1. reset subitem text */ + item.mask = LVIF_TEXT; + item.iItem = 0; + item.iSubItem = 1; + item.pszText = NULL; + r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item); + ok(r == 1, "ret %d\n", r); + + item.mask = LVIF_TEXT; + item.iItem = 0; + item.iSubItem = 1; + item.pszText = buffA; + buffA[0] = 'a'; + item.cchTextMax = sizeof(buffA); + r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item); + ok(r == 1, "ret %d\n", r); + ok(item.pszText[0] == 0, "got %p\n", item.pszText); + + /* 2. set new text with extra flag specified */ + item.mask = LVIF_TEXT | LVIF_DI_SETITEM; + item.iItem = 0; + item.iSubItem = 1; + item.pszText = text; + r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item); + ok(r == 1 || broken(r == 0) /* NT4 */, "ret %d\n", r); + + if (r == 1) + { + item.mask = LVIF_TEXT; + item.iItem = 0; + item.iSubItem = 1; + item.pszText = buffA; + buffA[0] = 'a'; + item.cchTextMax = sizeof(buffA); + r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item); + ok(r == 1, "ret %d\n", r); + ok(!memcmp(item.pszText, text, sizeof(text)), "got %s, expected %s\n", item.pszText, text); + } + /* Query param from subitem: returns main item param */ memset (&item, 0xcc, sizeof (item)); item.mask = LVIF_PARAM; -- 2.11.4.GIT