Reputation: 3156
In my CTreeCtrl derived class, I am acting on TVN_ITEMEXPANDED:
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, &OnTVNItemExpanded)
In the control's parent dialog, I also want to act upon the same notification, TVN_ITEMEXPANDED,
ON_NOTIFY(TVN_ITEMEXPANDED, IDC_ELEMENT_TREE, &OnTVNItemExpanded)
However, only the control class's OnTVNItemExpanded method is getting called, never my dialog's. I am using both breakpoints and seeing the desired behavior (or lack of desired behavior) in both methods to verify that only the control class's method is being called, not my dialog's method.
BUT, if I comment out the ON_NOTIFY_REFLECT from my CTreeCtrl-derived BEGIN_MESSAGE_MAP
, then my dialog's method gets called!?!
Why can't the notification go both to my control and to my dialog?!?
Upvotes: 2
Views: 3130
Reputation: 37192
ON_NOTIFY_REFLECT
overrides ON_NOTIFY
, but you can use ON_NOTIFY_REFLECT_EX
instead which lets your callback decide if the message should go through to the parent or not.
See Message Reflection for Windows Controls for a more detailed explanation:
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(). If you use ON_NOTIFY_REFLECT_EX() in your message map, your message handler may or may not allow the parent window to handle the message. If the handler returns FALSE, the message will be handled by the parent as well, while a call that returns TRUE does not allow the parent to handle it. Note that the reflected message is handled before the notification message.
Upvotes: 4