Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

I have a MFC dialog which is a parent window. This dialog contains several child windows which are dialogs themseleves having other child controls like button, edit box etc. My problem is that I need to change the default behaviour of the Enter key such that, no matter which child dialog is active and no matter which child control within the child dialog has the focus, on press of the Enter key (VK_RETURN), the parent window must be notified where I can handle it as I want.

PreTranslateMessage() fails for this scenario when the focus is on child control. What is the best way to tackle this problem? Would using ProcessMessageFilter() hit the performance?

Can any of you guide me on this? Sample code would be really helpful.

Thanks all...
Posted
Updated 19-May-10 3:05am
v3

1 solution

You can install an hook to trap the VK_RETURN key before it is dispatched to the active window.
You can find more informations on the MSDN library (see http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx[^] and related resources).
See the additional resources about WH_KEYBOARD and KeyboardProc callback procedure.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900