Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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:



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.

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Subclass a CRichEditCtrl, having trouble overriding OnNotify()
    ... 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. ... parent; if you return TRUE, ... If you have caught the reflection is is usually because you have extended the functionality of the control. ...
    (microsoft.public.vc.mfc)
  • Re: Transparent Graphic Background
    ... Not having ever had a transparent control overlapping any other control, I never realized that "Transparent" doesn't actually mean "transparent", but instead only means "draw the background with the parent's background color". ... One other point I might as well make, though you likely already understand it: the performance hit in the technique I posted is because the entire parent has to be copied with DrawToBitmap every time that the control moves. ... If you can avoid this, performance should be fine; the only way I know to avoid it is if the parent's contents are static, but of course if you figured out some way to get DrawToBitmap to draw only the portion of the parent you are interested in that would work as well. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to set a labels backcolor to transparent?
    ... The Transparent will set the control to be transparent with respect to its ... So Incase of the label, it will become transparent for the Form and if the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Transparent - does it work?
    ... Transparency works with respect to the parent. ... > put on top of some of the control. ... I make the panel transparent but it ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: BackColor on Transparent controls
    ... If I try to set the BackColor of my control I get the error "Control does not support transparent background colors" - its not a UserControl, ... The parent control backcolor will thus be returned as Transparent - it might be several parents up the chain to get an actual color, but I'll try recursing ands see if that works. ...
    (microsoft.public.dotnet.framework.windowsforms)