Solved

Disable ALT-F4

Posted on 1998-12-21
2
285 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
Comment Utility
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
Comment Utility
Thank you very much thresher.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

15 Experts available now in Live!

Get 1:1 Help Now