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
Solved

Message being 'eaten' by reflect macro

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 35
Use of condition with 'serial' in ansible 2 70
noX challenge 17 129
Message not shown 5 67
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.

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