Commit 7fdceb22 authored by James Hatheway's avatar James Hatheway Committed by Alexandre Julliard

Update selection after sorting (in LISTVIEW_SortItems) by making sure

selection list matches states of individual items.
parent 4e92e653
......@@ -7382,8 +7382,11 @@ static INT WINAPI LISTVIEW_CallBackCompare(
static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
int nCount;
int nCount, i;
UINT lStyle = GetWindowLongA(hwnd, GWL_STYLE);
HDPA *hdpaSubItems=NULL;
LISTVIEW_ITEM *pLVItem=NULL;
if (lStyle & LVS_OWNERDATA)
return FALSE;
......@@ -7401,6 +7404,20 @@ static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam)
DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, hwnd);
}
/* Adjust selections so that they are the way they should be after
the sort (otherwise, the list items move around, but whatever
is at the item's previous original position will be selected instead) */
for (i=0; i < nCount; i++)
{
hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, i);
pLVItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
if (pLVItem->state & LVIS_SELECTED)
LISTVIEW_AddSelectionRange(hwnd, i, i);
else
LISTVIEW_RemoveSelectionRange(hwnd, i, i);
}
/* align the items */
LISTVIEW_AlignTop(hwnd);
......
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