Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/comctl32/listview.c | 7 +++-- dlls/comctl32/tests/listview.c | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 2717812d0b..5bc4997922 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -4259,8 +4259,11 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL
memset(&nmlv, 0, sizeof(NMLISTVIEW)); nmlv.iItem = lpLVItem->iItem; - nmlv.uNewState = (item.state & ~stateMask) | (lpLVItem->state & stateMask); - nmlv.uOldState = item.state; + if(lpLVItem->mask & LVIF_STATE) + { + nmlv.uNewState = (item.state & ~stateMask) | (lpLVItem->state & stateMask); + nmlv.uOldState = item.state; + } nmlv.uChanged = uChanged ? uChanged : lpLVItem->mask; nmlv.lParam = item.lParam;
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 48612db54f..d54f149a2f 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -3473,6 +3473,55 @@ static void test_ownerdata(void) DestroyWindow(hwnd); }
+static void test_itemdatachange(void) +{ + static CHAR hello[] = "hello"; + LVITEMA item; + HWND hwnd; + DWORD res; + + hwnd = create_listview_control(LVS_REPORT); + + item.iSubItem = 0; + item.pszText = hello; + res = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item); + ok(res == 0, "should not fail\n"); + + memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview)); + memset(&item, 0, sizeof(item)); + item.mask = LVIF_STATE; + item.stateMask = LVIS_SELECTED; + item.state = LVIS_SELECTED; + res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item); + expect(TRUE, res); + + ok(g_nmlistview.iItem == 0, "got item %d\n", g_nmlistview.iItem); + ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem); + ok(g_nmlistview.uNewState == LVIS_SELECTED, "got new state 0x%08x\n", g_nmlistview.uNewState); + ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState); + ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged); + ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n"); + ok(g_nmlistview.lParam == 0, "got wrong lparam %d\n", g_nmlistview.lParam); + + memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview)); + memset(&item, 0, sizeof(item)); + item.iItem = 0; + item.lParam = 11; + item.mask = LVIF_PARAM; + res = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item); + expect(TRUE, res); + + ok(g_nmlistview.iItem == 0, "got item %d\n", g_nmlistview.iItem); + ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem); + ok(g_nmlistview.uNewState == 0, "got new state 0x%08x\n", g_nmlistview.uNewState); + ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState); + ok(g_nmlistview.uChanged == LVIF_PARAM, "got changed 0x%08x\n", g_nmlistview.uChanged); + ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n"); + ok(g_nmlistview.lParam == 11, "got wrong lparam %d\n", g_nmlistview.lParam); + + DestroyWindow(hwnd); +} + static void test_norecompute(void) { static CHAR testA[] = "test"; @@ -6492,6 +6541,7 @@ START_TEST(listview) test_sorting(); test_ownerdata(); test_norecompute(); + test_itemdatachange(); test_nosortheader(); test_setredraw(); test_hittest();
Please extend this test with remaining Listview styles, _ICON, _SMALLICON, and _LIST, running your new test in a loop for example.