Solved

Disable ALT-F4

Posted on 1998-12-21
2
315 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 533
fizzArray  challenge 1 84
Line meaning 9 86
"Black Box" Testing of Control System Software 2 52
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

809 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