?
Solved

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

Posted on 2007-11-16
10
Medium Priority
?
1,051 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 

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
 

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 1500 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
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.

764 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