I have a CEdit derived class and I am trying to catch the VK_RETURN and VK_ESCAPE in the ON_WM_KEYDOWN message handler. It does not seem to get called when pressing escape key or enter key. Any other key it gets called.
The problem is caused by the fact that the edit control was designed to be used in a dialog box. In a dialog box pressing Enter causes the dialog box to be dismissed with IDOK. Pressing Esc causes the dialog box to be dismissed with IDCANCEL. Because any of these keys closes the dialog box the authors found pointless to send any message.
You can force the Enter to be sent to you by specifiing the ES_WANTRETURN style for your edit control. This style will yield results only if you also specify the ES_MULTILINE style.
(Explanation: normally, in a multiline edit box, you can go to the begining of a new line using Ctrl+Enter. If you use ES_WANTRETURN, you will have that functionality just pressing Enter. In this case, as long as the focus is on that edit control, Enter will not close the dialog box.)