By default list control does not support deselecting an existing selection if we click on the same item. What I needed is to deselect an item if select an existing selected item.
I have implemented a virtual list and owner draw is enabled to draw custom row.
And handled the NM_CLICK event to deselect an already selected item.
What I am seeing on clicking an already selected item it getting deselected first. But suddenly the DrawItem() is invoked for all the items where the below condition is true for all items.
if ((lpDrawItemStruct->itemState & ODS_SELECTED) == ODS_SELECTED)
Please find the sample code at
https://github.com/ajayclouds/Sample/tree/main/virtuallist_demo[
^]. I will appreciate your help.
I used the sample code from
Using virtual lists[
^] and update the below things:
Enabled the
Owner Draw Fixed property of the list control. Then derived a class from CListCtrl and override DrawItem().
What I have tried:
I tried option like save the selections at the start of
OnCLickItem
and restored the state of all rows at the end of the
OnCLickItem
. But the problem not solved. Something is triggering DrawIitem with wrong item state.