Board index » delphi » D1 TEdit ENTER key Beep

D1 TEdit ENTER key Beep

Hi,

I have searched in D1 for a way to allow the user to use the ENTER and
RETURN keys just like the TAB key.  I couldn't find a property to allow
this.  I have written an OnkeyDown event handler to set the focus to the
next control, but D1 still beeps when the ENTER or RETURN key is
pressed.  How can I get rid of the beeping?

Thanks,
Don Leckie

 

Re:D1 TEdit ENTER key Beep


Quote
In article <346F740B.1...@leckieinc.com>, Donald A. Leckie wrote:
> I have searched in D1 for a way to allow the user to use the ENTER and
> RETURN keys just like the TAB key.  I couldn't find a property to allow
> this.  I have written an OnkeyDown event handler to set the focus to the
> next control, but D1 still beeps when the ENTER or RETURN key is
> pressed.  How can I get rid of the beeping?

Donald:

Try something like:

unit EnterTab;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TFrmEnterTab = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  FrmEnterTab: TFrmEnterTab;

implementation

{$R *.DFM}

{ The Form's KeyPreview property must be set to true }

procedure TFrmEnterTab.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = Chr(VK_RETURN) then begin
    if GetKeyState(VK_SHIFT) < 0 then
      SelectNext(ActiveControl, false, true)
    else
      SelectNext(ActiveControl, true, true);

    Key := #0;
  end;
end;

end.

Regards
Ralph (TeamB)
Herrsching, Germany, Mon, 17 Nov 1997 08:03 +0100 CET

Re:D1 TEdit ENTER key Beep


Quote
In article <346F740B.1...@leckieinc.com>, Donald A. Leckie wrote:
> but D1 still beeps

Just a small clarification: it is Windows that beeps, not Delphi.
Windows beeps whenever a keystroke isn't handled. In Ralph's code,
setting Key := #0 indicates to Windows that the key has been handled.

--
Rick Rogers (TeamB) | Fenestra Technologies

Re:D1 TEdit ENTER key Beep


Thank you Ralph.

Best Regards,
Don Leckie

Re:D1 TEdit ENTER key Beep


Thanks Rick.

Best Regards,
Don Leckie

Other Threads