CListCtrl selection change (2)
Posted on 2000-05-06
One of the most common events to be handled for listboxes is the fact that the item selection has changed. However I did not find any direct way of handling such event. What I am doing is Handling the LVN_ITEMCHANGED msg and using nasty condition like this:
void Foo::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
NM_LISTVIEW* pNMListView =(NM_LISTVIEW*)pNMHDR;
if (!(pNMListView->uOldState & LVIS_SELECTED) &&
(pNMListView->uNewState & LVIS_SELECTED)
|| (pNMListView->uOldState & LVIS_SELECTED) &&
!(pNMListView->uNewState & LVIS_SELECTED))
//do sth on selection change
Apart from the ugliness of this solution, the code under the condition is often called twice per one selection change (for item being deselected and for item that gets selected). I would like to have sth. that would work like LBN_SELCHANGE msg. for simple listbox.
Is there any nice solution?