Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable that an MFC application exits on pressing ESC or ALTF+F4?

Tags:

c++

windows

mfc

I have an MFC application, which i don't want to be closed during the running. I have disabled the "X" icon in the right upper corner, but now if i press the ESC key, or ALT+F4 it still closes.

How can i disable this, so it won't close, if someone press those keys? After the program has finished running i want to reenable them.

Thanks,
kampi

like image 222
kampi Avatar asked Dec 22 '22 05:12

kampi


1 Answers

If you handle the WM_CLOSE message and throw it away. (i.e. Don't call DefWindowProc), then the window won't close.

You could also register the window class with the CS_NOCLOSE style, to disable all of the normal ways of closing the window.

like image 160
John Knoeller Avatar answered Apr 20 '23 00:04

John Knoeller