?
Solved

Editbox trap Enter key

Posted on 1999-07-12
4
Medium Priority
?
414 Views
Last Modified: 2013-12-03
I am not using MFC.
I have a 1 line editbox as part of a dialog.  I would like to trap and process the Enter key instead of having the default button processed.  I have subclassed the editbox control and receive all messages except VK_RETURN.  I use spy++, which shows the editbox receiving a WM_KEYDOWN with wParam of VK_RETURN, but my processing loop never sees this!
Any Suggestions? Thank You, Ignatz
0
Comment
Question by:Ignatz
[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
  • 2
4 Comments
 
LVL 7

Expert Comment

by:leflon
ID: 1402733
can you give a sample of your message processing loop?
0
 

Author Comment

by:Ignatz
ID: 1402734
Here is a stripped down version:

LRESULT CALLBACK MyEditBoxProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
      switch (iMsg) {
      case WM_KEYDOWN:
vtest_msg("my.out","have key <%d>",wParam);
            switch (wParam) {
                  case VK_RETURN:
test_msg("pjc.out","have return");
                        return 0;
            } // switch on wParam if WM_KEYDOWN
            break;
      } // switch on message
      return (CallWindowProc((WNDPROC)GetWindowLong(hwnd,GWL_USERDATA),hwnd,iMsg,wParam,lParam));
} // MyEditBoxProc

vtest_msg() and test_msg() just dump to a file.
Thanks, Ignatz
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 800 total points
ID: 1402735
The edit control is asked whether it wants the return key or not by receiving a WM_GETDLGCODE. You should catch this and return DLGC_WANTRETURN and whatever else you want. Then you will get the return key.
0
 

Author Comment

by:Ignatz
ID: 1402736
Perfect, Thank You.
(I had to use DLGC_WANTALLKEYS. DLGC_WANTRETURN was undefined.)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

718 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