Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/comctl32/listview.c | 7 +++-- dlls/comctl32/tests/listview.c | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 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..f50c17e72f 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -3473,6 +3473,56 @@ static void test_ownerdata(void) DestroyWindow(hwnd); }
+static void test_itemdatachange(void) +{ + static const DWORD styles[] = { LVS_ICON, LVS_LIST, LVS_REPORT, LVS_SMALLICON }; + LVITEMA item; + HWND hwnd; + DWORD res; + int i; + + for(i =0; i < ARRAY_SIZE(styles); i++) + { + hwnd = create_listview_control(styles[i]); + + insert_item(hwnd, 0); + + 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 +6542,7 @@ START_TEST(listview) test_sorting(); test_ownerdata(); test_norecompute(); + test_itemdatachange(); test_nosortheader(); test_setredraw(); test_hittest();