Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 813
  • Last Modified:

Catching of selection changes in CListCtrl - how?

Hi:

I need to catch the moment when the user selects an item of the CListCtrl (to change some other dialog's controls). In the old good list box there was the LBN_SELCHANGE notification. How do I get similar notification for CListCtrl?

I tried to process the LVN_ITEMCHANGED notification:
void MyDialog:::OnItemchanged(  NMHDR* pNMHDR, LRESULT* pResult)
{
      NM_LISTVIEW *lv = (NM_LISTVIEW FAR *) pNMHDR;

    *pResult = 0;

    if( !(lv->uChanged & LVIF_STATE) )
                                return;

    UpdateMyDialog();
}

But the code never goes to the call to UpdateMyDialog when I select different items in the list.

Please, help!
0
asker
Asked:
asker
1 Solution
 
danny_pavCommented:
go to the MS site and find the MSJ code for control spy.
get it, and run it.  this will help a lot
0
 
Answers2000Commented:
LVN_SELCHANGE is the correct notification.  You are handling this wrong

void CMyDialog::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
      NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

      
      int nItem = m_list.GetNextItem( -1, LVNI_SELECTED ) ;

              // nItem is -1 is nothing selected, or index of the item
}

0
 
askerAuthor Commented:
In fact my code is correct and does work: the mistake was that I accidentally choosed to handle HDN_itemchanged instead of LVN_itemchanged in the ClassWizard. And it presents the same function name in both cases:-(

Well, the end-of-the-day mistake:-)

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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