Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 22 Dec 2006 21:33:47 -0500
The ON_NOTIFY_REFLECT_EX is useful if you want to extend the functionality transparently
without interfering with the parent's ability to respond to the event. For example, in my
dynamically-resizing combo box, the CBN_DROPDOWN message is important to me in the
control, so I handle it reflected. But I don't want to preclude the parent seeing this,
so after I resize the dropdown portion, I return FALSE, allowing the parent to take notice
of the fact that the dropdown has been dropped down. So it depends on whether you are
trying to extend something transparently, or want total control. You neither know nor
care if the parent handles it, since that is the purpose of doing the extension.
So there's no reason to try to send a special message to the parent.
joe
On Fri, 22 Dec 2006 20:05:11 GMT, Dan Bloomquist <public21@xxxxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]
bparsons wrote:
Joseph M. Newcomer wrote:
WM_NOTIFY messages are not sent to the rich edit control, they are sent to the *parent* of
the rich edit control. Therefore, unless you have figured out how to embed some control
as a child of your rich edit, you won't see any WM_NOTIFY messages in your subclass.
What you probably want is ON_NOTIFY_REFLECT or ON_NOTIFY_REFLECT_EX, which handle message
reflection. When MFC gets a WM_NOTIFY message, it changes it to a WM_NOTIFY_REFLECT
message and sends it back to the window from which it came. If it gets a FALSE return
(meaning there was no handler), it *then* searches its current message map for an OnNotify
handler. The ON_NOTIFY_REFLECT macro always returns "true", meaning the parent never sees
it. If you want to be transparent, or conditionally transparent, use
ON_NOTIFY_REFLECT_EX. If you return FALSE, the message will also be processed by the
parent; if you return TRUE, the parent never sees it.
joe
Where do I put the ON_NOTIFY_REFLECT() maco, in the control's
MESSAGE_MAP?
Yes.
Read technical notes 61 and 62. (TN061,TN062) Joe said it in a nutshell.
Thing about ON_NOTIFY_REFLECT_EX, it has a rather limited usefulness. If
you have caught the reflection is is usually because you have extended
the functionality of the control. You will want the parent to act/react
on this functionality and it is not there. You won't even know if the
parent handled the message.
The solution is to send your own message to the parent from this on
notify. Even make up your own NMHDRs if needed.
Best, Dan.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: Dan Bloomquist
- Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- References:
- Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: bparsons
- Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: Joseph M . Newcomer
- Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: bparsons
- Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- From: Dan Bloomquist
- Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- Prev by Date: Re: using GetDlgItem function in a thread
- Next by Date: Re: CString and UTF-8
- Previous by thread: Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- Next by thread: Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
- Index(es):
Relevant Pages
|