Solved

Message being 'eaten' by reflect macro

Posted on 2003-12-09
4
442 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
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 103
string initialization in java 11 113
ShiftLeft challenge 21 82
Problem to event 3 97
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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