Solved

Disable ALT-F4

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 123
Generic progress indicator 6 113
no14 challenge 14 62
twoTwo  challenge 35 93
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now