Discussion Locked

How to disable the "escape" key?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In my program, I want to prevent the running application from stopping by pressing the "escape" key. Could anybody tell me how to disable the "escape" key in the program?

P.S.:the program was written in Delphi, and it is used to comunicate with some smart terminals in real-time mode.

3 replies

by fenaikh

Hi
This is a part of the folowing topic from borland site.
good luck

Mohamed

"
Oh, one critical point: In order for this to work, the form's KeyPreview property must be set to True. Depending on the way your form handles KeyPress events, you might need to modify a few event handlers to accommodate this feature.

procedure TMainform.FormKeyDown(
Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then begin
if UseTray then Application.Minimize
else if CloseOnEscape then Close;
Key := 0;//optional; could prevent some weirdness
end;
end;

"
A Dozen Tips to Make Your Applications Work Like a Dream
http://www.borland.com/delphi/news/delphi_developer/dozentips.html

by bkfan

Mohamed ,

It seemed your code didn't work. My Do Loop in the program still stop as long as the 'escape' is pressed. What to do?

Ben

by parkin_thom

Be certain the KeyPreview property is set to TRUE on all components that could have the focus when the user presses ESCape.

THOM

This discussion is closed to new replies.