Board index » delphi » tEdit beeps!

tEdit beeps!

Hello,
I have a form with several tEdit components. I want to capture the
ESCAPE key
to close the form when the user presses ESC despite the control that has
focus.
So, I set:
  Form.KeyPreview:=true
  I write the ESCAPE handler on the OnKeyDown which calls Form.close;

Everything works ok up to here, but tEdit beeps by default when the
ESCAPE is
pressed while it has focus.
How can I bypass the beep ? I'm using D4 (I guess that it doesn't
matter)

Thanks, George Tsimperopoulos

 

Re:tEdit beeps!


George,
one way to supress the escape beep is to write an event handler for
TEdit.OnKeyPress (additional to the OnKeyDown):
.....
case Key of
  #27: Key := #0;
end;
.....

Best Regards,
Ingo

Quote
George Tsimperopoulos wrote:
> Hello,
> I have a form with several tEdit components. I want to capture the
> ESCAPE key
> to close the form when the user presses ESC despite the control that has
> focus.
> So, I set:
>   Form.KeyPreview:=true
>   I write the ESCAPE handler on the OnKeyDown which calls Form.close;

> Everything works ok up to here, but tEdit beeps by default when the
> ESCAPE is
> pressed while it has focus.
> How can I bypass the beep ? I'm using D4 (I guess that it doesn't
> matter)

> Thanks, George Tsimperopoulos

Other Threads