Solved

Message being 'eaten' by reflect macro

Posted on 2003-12-09
4
451 Views
Last Modified: 2013-11-20
I have a customised CEdit based class with a reflaect handler for the WM_KILLFOCUS message
      ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus)


In my dialog I have a control subclassed (via DDX, DDX_Control(pDX, IDC_DATE1, m_ctlDateBooking) ) and a message handler for the KillFocus
      ON_EN_KILLFOCUS(IDC_DATE1, OnKillfocusDateBooking)


However the OnKillfocusDateBooking in the dialog is never called, the reflected message handler is.  My understanding of the reflect is that the dialog should be given first crack at the message (I would want BOTH handlers to be called ideally but I can live with an extra line of code in the dialog to specifically call the fn in the edit based class).
0
Comment
Question by:AndyAinscow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9902748
See TN062: Message Reflection for Windows Controls.

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 TRUE, the message will be handled by the parent as well, while a call that returns FALSE does not allow the parent to handle it. Note that the reflected message is handled before the notification message.

Replace ON_CONTROL_REFLECT with ON_CONTROL_REFLECT_EX and declare handlers as
afx_msg BOOL memberFxn ( );

Return TRUE from it.
0
 
LVL 44

Author Comment

by:AndyAinscow
ID: 9902819
Many thanks.
There is one tiny problem.  If I return TRUE as you and the help files suggest the message is still eaten.  However returning false allows the dialog to receive the message as well.
I've got to test further.  This has reminded me of something some years ago.  On Win98 and on Win2000 one required a return of TRUE to do as the help files said, the other OP system required a return of FALSE.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9902861
Usually TRUE value returned from message handler stops message processing, so this is error in the Technical Note.
0
 
LVL 44

Author Comment

by:AndyAinscow
ID: 9903223
It runs OK on Win98 and Win2000.  Does look like a bug in help file.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question