How could I prevent esc from closing a dialog box?
I searched for this topic, but all I found was for MFC (You can overwrite PreTranslateMessage function in MFC). but my program is written in Windows API, not MFC.
I tried to catch all Keyboard messages in Dialog procedure, but none of them works. I also tried using subclassing in dialog box, but it didn't work too.
How could I do that? Thanks.
You can determine whether it's from the system menu easily enough -- check out the "return value" section of this MSDN page to see how.
If you can't determine whether it's from the ESCAPE key or a button, you could always get around that by using a different identifier for your Cancel button.