Alt+F4

How can I disable a form's Alt+f4 event without modifying the on close querry event(canclose:=false)
rayek007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ILECommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BTechoCommented:
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
SlavakCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

CleanupPingCommented:
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
snehanshuCommented:
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
Computer101Commented:
Forced accept

Computer101
E-E Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.