Link to home
Start Free TrialLog in
Avatar of Ignatz
Ignatz

asked on

Editbox trap Enter key

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
Avatar of leflon
leflon
Flag of Germany image

can you give a sample of your message processing loop?
Avatar of Ignatz
Ignatz

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ignatz

ASKER

Perfect, Thank You.
(I had to use DLGC_WANTALLKEYS. DLGC_WANTRETURN was undefined.)