tags:

views:

322

answers:

3

How to catch an ESC KeyPress using WndProc?

A: 

You need to catch the WM_CHAR message and check WParam.

SLaks
+4  A: 

Why are you doing it this way? Why not set the PreviewKey property of the Form to true and set a global event handler for KeyUp and check it...

if (e.KeyCode == Keys.Esc){
   //...
}
tommieb75
This won't work with certain keys, but it seems to work fine with the escape key. BTW, I believe it's KeyPreview.
Snarfblam
Sank's, I already do that. I'm just searching for alternative way )
Pritorian
A: 

(msg==WM_KEYDOWN) && (wParam==VK_ESCAPE) ... ops it was c#... sorry , that is win32 api way

luca