Solved

Overrule Alt-F4 event

Posted on 1998-08-26
1
192 Views
Last Modified: 2010-04-04
I want to prevent closing my delphi application by ALT-F4. I think that I have to write an Windowsmessage event handler, but how ?
Can i use the WM_CLOSE message to detect this ?
0
Comment
Question by:rene041697
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 100 total points
ID: 1337801
Hi,
Do the following simple steps:

1. Set Form's proterty KeyPreview := True;

2. Implement this simple event handler:

   procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
     Shift: TShiftState);
   begin
     if ( ( Key = VK_F4 ) and ( ssAlt in Shift ) )
     then Key := 0;
   end;

Note: this doesn't prevent the window from closing with the system menu or the close button.

/// John
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

20 Experts available now in Live!

Get 1:1 Help Now