Posted by webmaster Guido on June 08, 2003
In Reply to: Disable (again) posted by Joey on June 03, 2003
With just one line of code, you can disable the Alt-F4 key combination in a Delphi application.
Intercept all the keypresses at the level of the form, inspect which keys are pressed,
and suppress the keys if Alt+F4 was pressed. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key = VK_F4) and (ssAlt in Shift) then Key := 0; end; If F4 and ALT are pressed together, this procedure "swallows" the key. Any other key combination is passed on automatically to the next level (to a menu, or to a TEdit, a TButton,...) Suggested keywords: onkeydown, keypreview, keypress, onkeypress [ DelphiLand: free Delphi source code, tips, tutorials ] |
|