Commit 0588ba7f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Fix a regression caused by 9c1a0e46.

parent 42bef95c
......@@ -3565,7 +3565,7 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL
if (uChanged & LVIF_STATE)
{
if (lpItem && (stateMask & ~infoPtr->uCallbackMask & ~(LVIS_FOCUSED | LVIS_SELECTED)))
if (lpItem && (stateMask & ~infoPtr->uCallbackMask))
{
lpItem->state &= ~stateMask;
lpItem->state |= (lpLVItem->state & stateMask);
......@@ -3574,12 +3574,10 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL
{
if (infoPtr->dwStyle & LVS_SINGLESEL) LISTVIEW_DeselectAllSkipItem(infoPtr, lpLVItem->iItem);
ranges_additem(infoPtr->selectionRanges, lpLVItem->iItem);
lpItem->state |= LVIS_SELECTED;
}
else if (stateMask & LVIS_SELECTED)
{
ranges_delitem(infoPtr->selectionRanges, lpLVItem->iItem);
lpItem->state &= ~LVIS_SELECTED;
}
/* if we are asked to change focus, and we manage it, do it */
if (stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED)
......@@ -3597,13 +3595,11 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL
LISTVIEW_SetItemState(infoPtr, infoPtr->nFocusedItem, &item);
}
lpItem->state |= LVIS_FOCUSED;
infoPtr->nFocusedItem = lpLVItem->iItem;
LISTVIEW_EnsureVisible(infoPtr, lpLVItem->iItem, uView == LVS_LIST);
}
else if (infoPtr->nFocusedItem == lpLVItem->iItem)
{
lpItem->state &= ~LVIS_FOCUSED;
infoPtr->nFocusedItem = -1;
}
}
......
......@@ -1532,6 +1532,8 @@ static void test_ownerdata(void)
{
HWND hwnd;
LONG_PTR style, ret;
DWORD res;
LVITEMA item;
/* it isn't possible to set LVS_OWNERDATA after creation */
hwnd = create_listview_control(0);
......@@ -1579,6 +1581,22 @@ static void test_ownerdata(void)
style = GetWindowLongPtrA(hwnd, GWL_STYLE);
ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
DestroyWindow(hwnd);
/* try select an item */
hwnd = create_listview_control(LVS_OWNERDATA);
ok(hwnd != NULL, "failed to create a listview window\n");
res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
expect(0, res);
memset(&item, 0, sizeof(item));
item.stateMask = LVIS_SELECTED;
item.state = LVIS_SELECTED;
res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
expect(TRUE, res);
res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
expect(1, res);
DestroyWindow(hwnd);
}
START_TEST(listview)
......
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