Solved

Disabling Alt-F4 Close Behavior

Posted on 1998-11-17
3
513 Views
Last Modified: 2013-11-20
I'm writing an application which will be displayed in a kiosk. I've successfully disabled almost everything that could potentially close the app, except for the ALT-F4 Close combination.

Can someone tell me how to disable ALT-F4?

Things I've tried:
1)
// Turn System Keys (like windows, alt-tab, etc) off
UINT nOldVal;
SystemParametersInfo (SPI_SCREENSAVERRUNNING, 1, &nOldVal, 0);

Very handy for turning off Windows Menu, CTRL-ALT-DEL, etc, but not ALT-F4!

2) Create a key accelerator for ALT-F4 and map it to an empty method. This didn't work.

3) Try catching WM_SYSKEYDOWN message in PreTranslateMessage. It seemed that the app closes before that method is called.

Thanks for your help,
bre++
0
Comment
Question by:circuit
[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
3 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1324860
Answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324861
What you want to do is override the OnClose CWnd member function.  From what it looks like you've done already, you can probably figure out how to do this, but in any case:

1) Open your app's header.
2) Add:
   void OnClose ();

3) Open the CPP file
4) Add:
   void CMyApp::OnClose ()
   { }
5) Recompile

All done!

If you have any further questions regarding this problem, please feel free to ask.  Thanks!
0
 

Author Comment

by:circuit
ID: 1324862
You gotta put it on the window class, not the app. Works great though! Thanks.
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

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…
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 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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

737 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