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

Get WM_KEYDOWN from edit control

Posted on 1997-06-07
5
848 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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