Commit 740e7be1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Don't refuse to set subitem data when some extra flag is specified.

parent 7f640316
...@@ -4272,9 +4272,9 @@ static BOOL set_sub_item(const LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, ...@@ -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 particularly useful. We currently do not actually do anything with
the flag on subitems. 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; if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE | LVIF_STATE))) return TRUE;
/* get the subitem structure, and create it if not there */ /* get the subitem structure, and create it if not there */
hdpaSubItems = DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); hdpaSubItems = DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
assert (hdpaSubItems); assert (hdpaSubItems);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2006 Mike McCormack for CodeWeavers * Copyright 2006 Mike McCormack for CodeWeavers
* Copyright 2007 George Gov * Copyright 2007 George Gov
* Copyright 2009 Nikolay Sivov * Copyright 2009-2011 Nikolay Sivov
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -1030,10 +1030,11 @@ static void insert_item(HWND hwnd, int idx) ...@@ -1030,10 +1030,11 @@ static void insert_item(HWND hwnd, int idx)
static void test_items(void) static void test_items(void)
{ {
const LPARAM lparamTest = 0x42; const LPARAM lparamTest = 0x42;
static CHAR text[] = "Text";
char buffA[5];
HWND hwnd; HWND hwnd;
LVITEMA item; LVITEMA item;
DWORD r; DWORD r;
static CHAR text[] = "Text";
hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT, hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
10, 10, 100, 200, hwndparent, NULL, NULL, NULL); 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
...@@ -1140,6 +1141,55 @@ static void test_items(void) ...@@ -1140,6 +1141,55 @@ static void test_items(void)
r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item); r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
ok(r == 1, "ret %d\n", r); 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 */ /* Query param from subitem: returns main item param */
memset (&item, 0xcc, sizeof (item)); memset (&item, 0xcc, sizeof (item));
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment