Solved

Disable ALT-F4

Posted on 1998-12-21
2
329 Views
Last Modified: 2013-11-20
I have a full screen application which I would like to prevent exiting using ALT-F4.  How do I disable ALT-F4 from exiting my program?  The program is derived from CDialog and was written using MSVC 5.0.

Thanks for the help.
0
Comment
Question by:oblong
2 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 150 total points
ID: 1326541
To disable the ALT-F4 key combination, you want to override the OnClose member function of your application.  To do this, do the following:
1) Open Class Wizard
2) Override the WM_CLOSE message
3) Leave the function blank.  i.e. replace:
   void CMyDlg::OnClose ()
   { CDialog::OnClose (); }
   
   with

   void CMyDlg::OnClose ()
   { }

The ALT-F4 combination sends a WM_CLOSE message which is not acted upon with the blank function.  Note that this will also disable the use of double clicking the system menu since ALT-F4 and double clicking it are essentially the same thing.  Make sure you provide an alternative means for your program to exit though!  If you have any further questions on any of the above, please feel free to ask.  Thanks!
0
 

Author Comment

by:oblong
ID: 1326542
Thank you very much thresher.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 96
sum28 challenge 31 117
either24  challenge 19 105
Window placement 17 95
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question