Board index » delphi » My Edit Control beeps - help

My Edit Control beeps - help

Hi,
I am using an edit control to enter some characters. To show that input
is finished and according action should follow, I press return. In the
event ...Keydown I evaluate the Key and in case of VK_RETURN I call the
according function. Everything works fine - but it beeps!
What I think that happens: the return-event is passed further and having
no default button in the form it leads to a beep.

Can anyone help me to stop this. My neighbour gets already crazy about
my testing!

Thanks
Hans-Peter
--
Hans-Peter Haberlandner     |
Technodat CAD/CAM           | email: h...@technodat.co.at
Jakob Haringer-Strasse 6    | Phone: +43 - (0)662 454944 670
A-5020 Salzburg             | FAX:   +43 - (0)662 454944 9

 

Re:My Edit Control beeps - help


Thanks for your mail - but it did not work :-(

My code now:
procedure TTDZuordnungForm.edtKommFilterKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if Key = VK_RETURN then
  begin
   Action
   Key := 0;
  end;
end;

:-)
Hans-Peter
--
Hans-Peter Haberlandner     |
Technodat CAD/CAM           | email: h...@technodat.co.at
Jakob Haringer-Strasse 6    | Phone: +43 - (0)662 454944 670
A-5020 Salzburg             | FAX:   +43 - (0)662 454944 9

Re:My Edit Control beeps - help


Quote
Hans-Peter Haberlandner wrote:

> Hi,
> I am using an edit control to enter some characters. To show that input
> is finished and according action should follow, I press return. In the
> event ...Keydown I evaluate the Key and in case of VK_RETURN I call the
> according function. Everything works fine - but it beeps!
> What I think that happens: the return-event is passed further and having
> no default button in the form it leads to a beep.

> Can anyone help me to stop this. My neighbour gets already crazy about
> my testing!

Try setting

Key:=0;

in your OnKeyDown event.

Hope this helps

odair from brazil

Re:My Edit Control beeps - help


Quote
Hans-Peter Haberlandner wrote:

> Thanks for your mail - but it did not work :-(

> My code now:
> procedure TTDZuordnungForm.edtKommFilterKeyDown(Sender: TObject;
>   var Key: Word; Shift: TShiftState);
> begin
>   inherited;
>   if Key = VK_RETURN then
>   begin
>    Action
>    Key := 0;
>   end;
> end;

You avoid the beep by giving the edit control the style es_multiline. If you
make its size such that only one line can be accommodated and then intercept
the return key, it will behave as a single line edit without beep.

Re:My Edit Control beeps - help


Quote
Gerald Nunn wrote:

> Instead of KeyDown do it in the KeyPress event,

> if key=#13 then
>   Begin
>   Action;
>   Key:=#0;
>   End;

> That will work

> Cheers,
> Gerald

> In article <3459DEBE.2...@technodat.co.at>, Hans-Peter Haberlandner
> <h...@technodat.co.at> wrote:
> >Thanks for your mail - but it did not work :-(

> >My code now:
> >procedure TTDZuordnungForm.edtKommFilterKeyDown(Sender: TObject;
> >  var Key: Word; Shift: TShiftState);
> >begin
> >  inherited;
> >  if Key = VK_RETURN then
> >  begin
> >   Action
> >   Key := 0;
> >  end;
> >end;

> >:-)
> >Hans-Peter

> ----------------------------------------------
> Gerald Nunn, Toronto, Canada
> GExperts, 15 free add-in experts for Delphi
> http://www.amano-blick.com/~gnunn/GExperts.htm
> ----------------------------------------------

That's it! Thanks - also from my neighbour!

:-) Hans-Peter
--
Hans-Peter Haberlandner     |
Technodat CAD/CAM           | email: h...@technodat.co.at
Jakob Haringer-Strasse 6    | Phone: +43 - (0)662 454944 670
A-5020 Salzburg             | FAX:   +43 - (0)662 454944 9

Other Threads