Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Group Controls Pin
PJ Arends18-Jul-04 9:25
professionalPJ Arends18-Jul-04 9:25 
GeneralIntercepting Alt+F4 Pin
Joel Holdsworth16-Jul-04 8:31
Joel Holdsworth16-Jul-04 8:31 
GeneralRe: Intercepting Alt+F4 Pin
Antti Keskinen16-Jul-04 8:49
Antti Keskinen16-Jul-04 8:49 
GeneralRe: Intercepting Alt+F4 Pin
Joel Holdsworth16-Jul-04 9:32
Joel Holdsworth16-Jul-04 9:32 
GeneralRe: Intercepting Alt+F4 Pin
Mike Dimmick16-Jul-04 9:46
Mike Dimmick16-Jul-04 9:46 
GeneralRe: Intercepting Alt+F4 Pin
Joel Holdsworth16-Jul-04 10:01
Joel Holdsworth16-Jul-04 10:01 
GeneralRe: Intercepting Alt+F4 Pin
Mike Dimmick16-Jul-04 10:23
Mike Dimmick16-Jul-04 10:23 
GeneralRe: Intercepting Alt+F4 Pin
Antti Keskinen16-Jul-04 12:40
Antti Keskinen16-Jul-04 12:40 
Override the window procedure function. If message is WM_CLOSE, ignore it and return zero. This disables Alt+F4 usage completely. However, for a more effective solution, create a boolean variable inside the window's class. When the user attempts to quit the application by using a "legimate way", such as a menu selection or pressing the X button, then set the boolean to true, and allow the WM_CLOSE message to pass through, thus ending the application.

Your application can still be closed by pressing ESC or ENTER/RETURN, if it is a dialog-based application. Both methods are easy to disable: monitor for WM_KEYDOWN messages, and if the message is generated by ESC/RETURN/ENTER, ignore and return zero. Again, using a boolean variable allows to know whether it's a "legimate" press or an accidental one (entering a number into a field and pressing ENTER, for example)

If it is a standard Windows-application (non-dialog), then the ESC/RETURN/ENTER make no difference, I think. But you should test them all out nevertheless, as I don't want a 800 ton weight to drop on me Smile | :)

For all other key combinations used to end an application, here's perhaps-a-complete list: CTRL+F4, ALT+F4, ESC, RETURN and ENTER.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralCredUIConfirmCredentials Pin
Anthony988716-Jul-04 7:59
Anthony988716-Jul-04 7:59 
GeneralRe: CredUIConfirmCredentials Pin
David Crow16-Jul-04 8:21
David Crow16-Jul-04 8:21 
GeneralRe: CredUIConfirmCredentials Pin
Anthony988717-Jul-04 3:01
Anthony988717-Jul-04 3:01 
GeneralOpening explorer and selecting a file Pin
Andy Moore16-Jul-04 7:26
Andy Moore16-Jul-04 7:26 
GeneralRe: Opening explorer and selecting a file Pin
David Crow16-Jul-04 8:12
David Crow16-Jul-04 8:12 
QuestionGraphic card problem????? Pin
newbeetoc16-Jul-04 7:16
newbeetoc16-Jul-04 7:16 
AnswerRe: Graphic card problem????? Pin
Chris Losinger16-Jul-04 9:01
professionalChris Losinger16-Jul-04 9:01 
GeneralRe: Graphic card problem????? Pin
newbeetoc16-Jul-04 9:09
newbeetoc16-Jul-04 9:09 
GeneralAutomatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 7:13
Andy Moore16-Jul-04 7:13 
GeneralRe: Automatically determing Save File Dialog filter type Pin
palbano16-Jul-04 7:29
palbano16-Jul-04 7:29 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 7:44
Andy Moore16-Jul-04 7:44 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Maximilien16-Jul-04 8:04
Maximilien16-Jul-04 8:04 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 8:07
Andy Moore16-Jul-04 8:07 
GeneralRe: Automatically determing Save File Dialog filter type Pin
David Crow16-Jul-04 8:16
David Crow16-Jul-04 8:16 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 10:08
Andy Moore16-Jul-04 10:08 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Maximilien16-Jul-04 7:46
Maximilien16-Jul-04 7:46 
GeneralCustom data type in ActiveX property Pin
iluha16-Jul-04 7:12
iluha16-Jul-04 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.