CListCtrl Selection of Item Problem
-
Problem- When I click on the empty space after any item or after all items then the current item selection goes away and I have no way to highlight previous item. (Though I have pervious selected item index). This is beacuse when item is selected MFC gives us two messages 1. Pervious Item Deselected. 2. Current item Selected. But when we click on empty area then 1) it gives message - Item Deselected ... and there is no other message again .... So we cant track whether you get 1 or 2 message from MFC.... This is all my perception about CListCtrl behaviour Does any one have a way to this problem???? Thanks in Advance :)
AmolM
-
Problem- When I click on the empty space after any item or after all items then the current item selection goes away and I have no way to highlight previous item. (Though I have pervious selected item index). This is beacuse when item is selected MFC gives us two messages 1. Pervious Item Deselected. 2. Current item Selected. But when we click on empty area then 1) it gives message - Item Deselected ... and there is no other message again .... So we cant track whether you get 1 or 2 message from MFC.... This is all my perception about CListCtrl behaviour Does any one have a way to this problem???? Thanks in Advance :)
AmolM
-
You can catch the OnSelChangeListCtrl(...) and always keep the index of the previously selected item. Once you get that there is no selected item (when clicking under the last item) just call ListCtrl.SetItemState(PrevSelItem, LVIS_SELECTED, LVIS_SELECTED);
Sorry, but I didnt find any message like OnSelChangeListCtrl() for CListCtrl. I have captured 1) OnItemchangedList1() and 2) OnItemchangingList1() And the scenario was like the problem I posted.... I just can get the item selected or not :( Sequence of message is like 1) Previous item de-selected and 2) Current Item Selected ==> in case item is selected... Otherwise only 1st message.... if item is not selected (Clicked on empty area) Any Commments on this... Thanks for previous reply Thanks in Advance :)
AmolM
-
Sorry, but I didnt find any message like OnSelChangeListCtrl() for CListCtrl. I have captured 1) OnItemchangedList1() and 2) OnItemchangingList1() And the scenario was like the problem I posted.... I just can get the item selected or not :( Sequence of message is like 1) Previous item de-selected and 2) Current Item Selected ==> in case item is selected... Otherwise only 1st message.... if item is not selected (Clicked on empty area) Any Commments on this... Thanks for previous reply Thanks in Advance :)
AmolM
Aamol M wrote:
- OnItemchangedList1() and
Which is what GuyM was referring to as
OnSelChangeListCtrl()
. Whatever you are calling it, when theLVN_ITEMCHANGED
notification is received, look at theuNewState
member to see if it isLVNI_SELECTED
. If so, save the item's value.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne