Solved

Message being 'eaten' by reflect macro

Posted on 2003-12-09
4
435 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
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
It runs OK on Win98 and Win2000.  Does look like a bug in help file.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 52
Host to IP 7 73
List out all word 7 219
Line meaning 9 75
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now