I have a CListCtrl in a CFormView that represents objects. In the form view I have controls that represent data of the selected object. When a new object is selected in the list, I need to: 1. validate the data 2. if the data is not valid, keep the original list item selected, and do not select the new item. 3. if the data is valid, then show the data of the new object. I have added OnItemchangingX and OnItemchangedX for the list control to my form view class.
void CAddonView::OnItemchangingX(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
BOOL bValidateSuccessful = validate();
if (!bValidateSuccessful) {
--------------------------------------------------
...what do I do here to keep the old item selected
...and keep the new one from getting selected?
--------------------------------------------------
}
}
void CAddonView::OnItemchangedX(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
int iSelItem = m_listAP.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
if (iSelItem != -1 && pNMListView->uNewState & LVIS_SELECTED)
{
...load data of newly selected item...
}
}
What do I need to do to keep the old selection if the validation fails? Thanks. -- David Hisel Internet Business Software