PDA

Click to See Complete Forum and Search --> : virtual key


Fengling
Apr 30th, 2002, 12:30 PM
Hi,
Does somebody know how to capture the Enter key?
In my Visual c++ 5.0 program, i use the WM_KEYDOWN to capture the key press, I can capture most of the keys, like F1,F2,A,B,C....but Enter and Esc and a few others I can not. help please.

thanks

[Digital-X-Treme]
Apr 30th, 2002, 01:03 PM
esc = Ascii code 27.
enter/return = Ascii code 13.

Fengling
Apr 30th, 2002, 01:06 PM
yes, I know the key value. My problem is that when I hit the Enter or Esc key, the program does not go to the WM_KEYDOWN function.

parksie
Apr 30th, 2002, 02:18 PM
That's because they're already captured for things like the default button. Are you using a dialogue rather than a raw window?

Fengling
Apr 30th, 2002, 02:30 PM
Yes, I am using CBitmapDialog, which is based on CDialog.
I do not have any butttons on it, just some static lables. If the Enter and Esc are captured by default, where? and how can I change the default setting? Thanks.

CornedBee
May 1st, 2002, 02:19 PM
In MFC you can probably override the PreTranslateMessage function. In WinAPI I believe it to be impossible with normal dialogs (it may be impossible with the common dialogs in MFC too).

Fengling
May 1st, 2002, 02:28 PM
yes, you are right. I do need override the PreTranslateMessage function. It works OK now.

Thanks again,guys.;)