Solved

Get WM_KEYDOWN from edit control

Posted on 1997-06-07
5
842 Views
Last Modified: 2013-12-03
Hi,
I have a smaller problem with Win32 API. I have created an edit control in my modeless application window (not a dialog window), and I would like to receive a message to the parent window when pressing Enter, arrow keys etc. Currently, I only receive messages when changing the contents of the edit control.

I have searched for a "parent notify" style, but there is no such thing. Please help if you can, thanks.
0
Comment
Question by:mnp
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 200 total points
ID: 1397921
WM_ParentNotify is not triggered buy KeyDown events, so you will have  to process the KeyDown inside your modless window's message loop and call SendMessage() to the parrent window whenever you recieve a key event.
0
 

Author Comment

by:mnp
ID: 1397922
My problem is to receive the WM_KEYDOWN message! I have ONE modeless window with a window procedure, including an edit control as a child window, nothing else. So how can I process the messages sent only to the edit control (like WM_KEYDOWN)?
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1397923
Well, In that case, CEdit is derived from CWND, so it will recieve a WM_KEYDOWN message, and by default behaviour, forward it to its parent window (at which point its getting lost).

What you can do is to subclass your CEdit control and process the WM_KEYDOWN there, leaving the rest of the controls behaviour unchanged.
0
 

Author Comment

by:mnp
ID: 1397924
I'm not using MFC, but native WinAPI. I've found a solution though (got the idea from another question on ee). I just changed the window procedure for the "EDIT" class to one of my own, and redirected all messages to the default procedure. It works just fine!
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1397925
Good to hear it! :-)

Thats exactly what goes on internaly in MFC when you subclass CEdit..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

895 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

15 Experts available now in Live!

Get 1:1 Help Now