Solved

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

Posted on 2007-11-16
10
1,021 Views
Last Modified: 2013-12-14
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
0
Comment
Question by:sternocera
  • 5
  • 5
10 Comments
 
LVL 19

Expert Comment

by:alb66
ID: 20297806
0
 

Author Comment

by:sternocera
ID: 20297925

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
 
LVL 19

Expert Comment

by:alb66
ID: 20297968
try this:

NOTIFY_HANDLER(IDC_LIST_PRODUCTS_ADDED, LVN_ODSTATECHANGED, OnListSelChanged)
0
 

Author Comment

by:sternocera
ID: 20297987
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
 
LVL 19

Expert Comment

by:alb66
ID: 20298046
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:sternocera
ID: 20298069
alb66,

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

Thanks
0
 
LVL 19

Expert Comment

by:alb66
ID: 20298141
0
 

Author Comment

by:sternocera
ID: 20298171
Aren't these messages only for windows CE?
0
 
LVL 19

Accepted Solution

by:
alb66 earned 500 total points
ID: 20298239
No, they are also present in Windows since Windows95

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

Author Comment

by:sternocera
ID: 20298328
This works for me:

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


Thanks,
Sternocera
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
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.

760 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

21 Experts available now in Live!

Get 1:1 Help Now