MFC / C++: What message indicates that the selection of a CListCtrl has changed?

Hello,

I have a ClistCtrl in a dialog that displays data that can be changed with/are reflected by various form widgets, mostly CEdits. I'd like to catch any MFC messages sent by the CListCtrl that indicate that the user's focus has changed (i.e that they have clicked on a different row of the ClistCtrl), so that I can update the form widgets as appropriate.

How can this be done?

Regards,
Sternocera
sternoceraAsked:
Who is Participating?
 
alb66Connect With a Mentor Commented:
No, they are also present in Windows since Windows95

http://msdn2.microsoft.com/en-us/library/bb774845.aspx
0
 
alb66Commented:
0
 
sternoceraAuthor Commented:

BEGIN_MESSAGE_MAP(CBatchAdd, CDialog)
NOTIFY_HANDLER(IDC_LIST_PRODUCTS_ADDED, LVN_ODSTATECHANGED,&CBatchAdd:: OnListSelChanged)
END_MESSAGE_MAP()

This seems to cause all kinds of errors. I guess I got something wrong. What should I do to handle the message?

Regards,
Sternocera
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
alb66Commented:
try this:

NOTIFY_HANDLER(IDC_LIST_PRODUCTS_ADDED, LVN_ODSTATECHANGED, OnListSelChanged)
0
 
sternoceraAuthor Commented:
Curiously, this causes the following error message:

error C3861: 'NOTIFY_HANDLER': identifier not found

Plus a whole bunch of syntax errors arising from that.

Is this an MFC handler or an ATL handler?

Regards,
Sternocera
0
 
alb66Commented:
It's an ATL handler.

Try the following:

ON_NOTIFY_REFLECT(LVN_ODSTATECHANGED, OnListSelChanged)

void CBatchAdd::OnListSelChanged( NMHDR *pNMHDR, LRESULT *pResult )
{
      LPNMLVODSTATECHANGE pNMLV = reinterpret_cast<LPNMLVODSTATECHANGE>( pNMHDR );
      ...
}
0
 
sternoceraAuthor Commented:
alb66,

That will build, but doesn't appear to do anything,

Thanks
0
 
alb66Commented:
0
 
sternoceraAuthor Commented:
Aren't these messages only for windows CE?
0
 
sternoceraAuthor Commented:
This works for me:

ON_NOTIFY( LVN_ITEMCHANGED, IDC_LIST_PRODUCTS_ADDED, &CBatchAdd::OnListSelChanged)


Thanks,
Sternocera
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.