?
Solved

Get WM_KEYDOWN from edit control

Posted on 1997-06-07
5
Medium Priority
?
863 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
[X]
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
  • 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

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

765 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