?
Solved

Alt+F4

Posted on 2003-03-01
6
Medium Priority
?
592 Views
Last Modified: 2010-04-04
How can I disable a form's Alt+f4 event without modifying the on close querry event(canclose:=false)
0
Comment
Question by:rayek007
[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
6 Comments
 
LVL 3

Accepted Solution

by:
ILE earned 100 total points
ID: 8049649
100% working solution

u must first do


procedure TForm1.FormCreate(Sender: TObject);
begin
form1.keypreview:=true;
end;


procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (shift=[ssalt])  and (key=vk_f4) then key:=0;
end;



easy arent?
0
 
LVL 3

Assisted Solution

by:BTecho
BTecho earned 100 total points
ID: 8054547
Hello

If you happen to use a TMainMenu or TPopupMenu you easily prevent alt+f4 like so.

Just add a new item to the menu set its shortcut to Alt+F4 set the Visible property to false. On the Onclick event of the item just put some commented code.

Thats it!
0
 
LVL 3

Expert Comment

by:Slavak
ID: 8055676
when you press Alt+F4, windows sends WM_CLOSE message to currently active window.

If you want to change the default behaviuor just ovveride the message:


Type
  TForm1 = class(TForm)
  ...
  private
    procedure WMClose(var Msg : TMessage); message WM_CLOSE;
  ...
  end;


procedure TForm1.WMClose(var Msg : TMessage);
begin
// for default behaviour call to inherited
end;




0
Technology Partners: 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!

 

Expert Comment

by:CleanupPing
ID: 9316989
rayek007:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9999597
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Split between ILE and BTecho

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer

P.S.
  Only 50 points so can't give points to Slavak also.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 10029527
Forced accept

Computer101
E-E Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 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