Board index » delphi » Help: Beep in TEdit Component

Help: Beep in TEdit Component

I think it's just a simple question for you.

Does anybody know how I can supress the BEEP in a TEdit component while
pressing the RETURN key?

Thank you in advance.

Philipp Schade

 

Re:Help: Beep in TEdit Component


In article <4pm7ei$...@news00.btx.dtag.de>,
   Fam.Dr.Lutz.Sch...@t-online.de (Philipp Schade) wrote:
]-I think it's just a simple question for you.
]-
]-Does anybody know how I can supress the BEEP in a TEdit component while
]-pressing the RETURN key?
]-
]-Thank you in advance.
]-
]-Philipp Schade

Trap the <Enter> key in the TEdit's OnKeyPress handler.

Here's the sort of thing I've been using to make the
<Enter> key behave like the <Tab> key in a TEdit...

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
  BEGIN
    if (Key = #13) then    {= gotcha! =}
      BEGIN
        Key := #0;         {= kill the beep =}
        PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);   {= move to next tab stop =}
      END;
  END;

Mark Vaughan

Re:Help: Beep in TEdit Component


Quote
Fam.Dr.Lutz.Sch...@t-online.de (Philipp Schade) wrote:
>I think it's just a simple question for you.
>Does anybody know how I can supress the BEEP in a TEdit component while
>pressing the RETURN key?
>Thank you in advance.
>Philipp Schade

Here's a bit of code.

Use the OnKeyPress event.

procedure TForm1.Edit1KeyPress;
begin
  If Key = #13 then
     Key := #0;
end;

Bruce.

Re:Help: Beep in TEdit Component


Quote
> Does anybody know how I can supress the BEEP in a TEdit component while
> pressing the RETURN key?

Try to handle the OnKeyPress event...

If key=#13 then key:=#0 {A think it works..}

Re:Help: Beep in TEdit Component


Quote
Fam.Dr.Lutz.Sch...@t-online.de (Philipp Schade) wrote:
>I think it's just a simple question for you.
>Does anybody know how I can supress the BEEP in a TEdit component while
>pressing the RETURN key?
>Thank you in advance.
>Philipp Schade

In the form's OnKeyPress event:

        if Key = #13 then
                Key = #0;       <-- this gobbles up the BEEP

Other Threads