Reputation: 22285
If I want to change the focus item in the ListView control I do the following:
BOOL setListFocusItem(CListCtrl* pList, int nIndex)
{
return !!pList->SetItemState(nInd, LVIS_FOCUSED, LVIS_FOCUSED);
}
Is this the way you do it?
Because the focus itself changes but there's one issue that this creates. For instance, if the list had 100 items and the focus was on item 1. If I then call my method as such setListFocusItem(99);
the focus changes to item 99, but then if I shift-click on item 90, I would expect the list to have items 90 through 99 to be selected. But instead the list selects items 1 through 90. So obviously my setListFocusItem()
method does not change the shift-click "first" location. So question is how to make it do it?
Upvotes: 2
Views: 1308
Reputation: 37192
Short answer : use the LVM_SETSELECTIONMARK
message.
(In MFC-ese, CListCtrl::SetSelectionMark
).
Upvotes: 3