Solved

Catching of selection changes in CListCtrl - how?

Posted on 1998-10-14
3
716 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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