[All]
'Beep' sound when hitting <Enter> on a TEdit
Obsah: 'Beep' sound when hitting on a TEdit
'Beep' sound when hitting <Enter> on a TEdit
Product Name:��C++Builder�
Product Version:��All�
Product Component:��VCL�
Platform/OS Version:� All
Description:
���� In a C++Builder application, when a TEdit or similar control has focus and the <Enter> key is pressed, there is a 'beep' sound. Why does this happen, and what can I do to stop it?
Answer/Solution:
���� The 'beep' heard when hitting <Enter> for a TEdit or similar control is the default behavior of a Windows single line edit control. The TEdit understands <Enter> to be an invalid keypress for this kind of control, and that's why it generates the 'beep'.
�
���� If the 'beep' is bothersome, then you can stop it by using the OnKeyPress event handler to trap and disable presses of the <Enter> key, like so:
���� //--------------------
���� void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
���� {
��������� if (Key == VK_RETURN)
���� ��������� Key = 0;
���� }
���� //--------------------
Author:� Yu-Chen Hsueh