Link to home
Start Free TrialLog in
Avatar of sternocera
sternocera

asked on

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
Avatar of alb66
alb66
Flag of Italy image

Avatar of sternocera
sternocera

ASKER


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
try this:

NOTIFY_HANDLER(IDC_LIST_PRODUCTS_ADDED, LVN_ODSTATECHANGED, OnListSelChanged)
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
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 );
      ...
}
alb66,

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

Thanks
Aren't these messages only for windows CE?
ASKER CERTIFIED SOLUTION
Avatar of alb66
alb66
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works for me:

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


Thanks,
Sternocera