Solved

Get WM_KEYDOWN from edit control

Posted on 1997-06-07
5
837 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Good to hear it! :-)

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
This video discusses moving either the default database or any database to a new volume.

771 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

10 Experts available now in Live!

Get 1:1 Help Now