Child messages not being recieved by parent
Posted on 2008-06-17
I have a CDialog based class that creates more CDialog based classes. Like this:-
m_pDetailsTab = new CCarriageCostsDetailsDlg(m_Zones, m_WeightBands, m_Services, this);
m_pPricesTab = new CCarriageCostsPricesDlg;
The problem is I want to handle the BN_CLICKED of a button on CCarriageCostsDetailsDlg in CCarriageCostsDlg. Like this:-
ON_NOTIFY(BN_CLICKED, IDC_BUTTON_APPLY, OnClickedButtonApply)
ON_NOTIFY(BN_CLICKED, IDC_BUTTON_EDIT, OnClickedButtonEdit)
But these events are not recieved. I know I can use a pointer within CCarriageCostsDetailsDlg and call a public method within CCarriageCostsDlg or Post/Send a custom message but that is very bad and ugly code so would like to do this the 'correct' way.
Is there something wrong with my ON_NOTIFY? according to MSDN this should work.
To Quote MSDN:-
"If, in your parent window class, you supply a handler for a specific WM_NOTIFY message or a range of WM_NOTIFY messages, your handler will be called only if the child control sending those messages does not have a reflected message handler through ON_NOTIFY_REFLECT()."
It does not have a ON_NOTIFY_REFLECT().