Handle the case where the function SetItem is called to select an item
or set its focus.
This commit is contained in:
parent
fddc3e15d8
commit
9024c107bf
@ -1204,10 +1204,16 @@ static BOOL LISTVIEW_SetItemFocus(HWND hwnd, INT nItem)
|
|||||||
|
|
||||||
if (infoPtr->nFocusedItem != nItem)
|
if (infoPtr->nFocusedItem != nItem)
|
||||||
{
|
{
|
||||||
bResult = TRUE;
|
if (infoPtr->nFocusedItem >= 0)
|
||||||
ZeroMemory(&lvItem, sizeof(LVITEMA));
|
{
|
||||||
lvItem.stateMask = LVIS_FOCUSED;
|
INT oldFocus = infoPtr->nFocusedItem;
|
||||||
ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);
|
bResult = TRUE;
|
||||||
|
infoPtr->nFocusedItem = -1;
|
||||||
|
ZeroMemory(&lvItem, sizeof(LVITEMA));
|
||||||
|
lvItem.stateMask = LVIS_FOCUSED;
|
||||||
|
ListView_SetItemState(hwnd, oldFocus, &lvItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
lvItem.state = LVIS_FOCUSED;
|
lvItem.state = LVIS_FOCUSED;
|
||||||
lvItem.stateMask = LVIS_FOCUSED;
|
lvItem.stateMask = LVIS_FOCUSED;
|
||||||
@ -1931,6 +1937,30 @@ static BOOL LISTVIEW_SetItem(HWND hwnd, LPLVITEMA lpLVItem)
|
|||||||
{
|
{
|
||||||
nmlv.uNewState = lpLVItem->state & lpLVItem->stateMask;
|
nmlv.uNewState = lpLVItem->state & lpLVItem->stateMask;
|
||||||
nmlv.uOldState = lpItem->state & lpLVItem->stateMask;
|
nmlv.uOldState = lpItem->state & lpLVItem->stateMask;
|
||||||
|
|
||||||
|
if (nmlv.uNewState & LVIS_SELECTED)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This is redundent if called through SetSelection
|
||||||
|
*
|
||||||
|
* however is required if the used directly calls SetItem
|
||||||
|
* to set the selection.
|
||||||
|
*/
|
||||||
|
LISTVIEW_RemoveSelections(hwnd, 0, lpLVItem->iItem-1);
|
||||||
|
LISTVIEW_RemoveSelections(hwnd, lpLVItem->iItem + 1,
|
||||||
|
GETITEMCOUNT(infoPtr));
|
||||||
|
}
|
||||||
|
else if (nmlv.uNewState & LVIS_FOCUSED)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This is a fun hoop to jump to try to catch if
|
||||||
|
* the user is calling us directly to call focuse or if
|
||||||
|
* this function is being called as a result of a
|
||||||
|
* SetItemFocuse call.
|
||||||
|
*/
|
||||||
|
if (infoPtr->nFocusedItem >= 0)
|
||||||
|
LISTVIEW_SetItemFocus(hwnd, lpLVItem->iItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nmlv.uChanged = uChanged;
|
nmlv.uChanged = uChanged;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user