Solved

Catching of selection changes in CListCtrl - how?

Posted on 1998-10-14
3
744 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 6 60
Window placement 17 81
tripleUp challenge 7 78
FizzBuzz challenge 9 80
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

785 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