Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable ALT-F4

Posted on 1998-12-21
2
Medium Priority
?
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 600 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

609 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