Win32 C ++ detecting 'enter' in an edit control without a subclass?

Basically, I want Enter to trigger a message that I can catch when the control focus of the management board and the user press the enter key. All the solutions on the Internet seem to be related to a subclass, but I was wondering if it has another way?

For example, my button has the identifier ID_BUTTON_SEND. Here is how I imagine it:

case WM_COMMAND:
     switch (LOWORD(wParam))
            case ID_BUTTON_SEND
                 if ('enter was pressed') 
                      do this
                 else
                      default

... you have an idea :) I read http://support.microsoft.com/kb/102589 , but frankly option 1 doesn’t make sense to me.

Greetings

+5
source share
3 answers

- TranslateMessage. , MFC, CWnd:: PreTranslateMessage. Win API, , , TranslateMessage.

+3

, , , * ID_BUTTON_SEND *. , , .

, , , foucs, * ID_BUTTON_SEND * .

, BS_DEFPUSHBUTTON GWL_STYLE.

+3

Just repeat the article in KB. For option 1, you can simply handle the IDOK in WM_COMMAND.

case WM_COMMAND:
  if(wParam == IDOK){
     ENTER WAS PRESSED
  }else{
    REGULAR EVENT HANDLING
  }

This is a much simpler and clearer way to check input.

+2
source

All Articles