• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

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
0
Ignatz
Asked:
Ignatz
  • 2
1 Solution
 
leflonCommented:
can you give a sample of your message processing loop?
0
 
IgnatzAuthor Commented:
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
 
Tommy HuiEngineerCommented:
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
 
IgnatzAuthor Commented:
Perfect, Thank You.
(I had to use DLGC_WANTALLKEYS. DLGC_WANTRETURN was undefined.)
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now