Home   |   Software   |   Practical Jokes   |   Code Corner   |   Workshops


Delphi Secret #14

Disabling ALT-F4 to Prevent Closing a Form
 
 
     If you need to have users close a form the way you want them to, this secret can help. Users will be unable to close a form by pressing Alt+F4.

Important: You will need to have the KeyPreview property set to true for the desired form.

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







This page was developed by FoxWare Design & Support.
Hosted by www.Geocities.ws

1