Solved

Catching of selection changes in CListCtrl - how?

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 134
deburging in oracle form 12 112
Line meaning 9 91
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 185
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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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