• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1506
  • Last Modified:

ListView_SetItemState

In my list view I want to highlight the item at the current cursor position. I used ListView_SetItemState with LVIS_SELECTED to highlight the item. The problem is that when the cursor moves to a new item I want to highlight the new item and clear the state of the previous item. If I have the index to the previous item how can I clear its highlighted state?
0
nadirkamal
Asked:
nadirkamal
1 Solution
 
vesselCommented:
hi nadirkamal!

This call will clear the item's highlighted state:
ListView_SetItemState(hwndX, nIndex, 0, LVIS_SELECTED);
and this will select the item:
ListView_SetItemState(hwndX, nIndex, LVIS_SELECTED, LVIS_SELECTED);

ListView_SetItemState(
    HWND hwnd,
    int i,
    UINT state, // 0 if you want to clear bits
                  // or flags (LVIS_SELECTED) to set
    UINT mask   // Bits which you want to set or clear
);
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now