Solved

Catching of selection changes in CListCtrl - how?

Posted on 1998-10-14
3
733 Views
Last Modified: 2013-11-20
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
Comment
Question by:asker
3 Comments
 
LVL 3

Expert Comment

by:danny_pav
ID: 1323295
go to the MS site and find the MSJ code for control spy.
get it, and run it.  this will help a lot
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 150 total points
ID: 1323296
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
 

Author Comment

by:asker
ID: 1323297
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now