Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Quitar sonido de error al pulsar Enter (https://www.clubdelphi.com/foros/showthread.php?t=59365)

madiazg 24-08-2008 12:34:22

Quitar sonido de error al pulsar Enter
 
Hola, ¿alguien puede indicarme si es posible quitar el sonido de error cuando se pulsa ENTER en un TEdit?

El código que tengo es el siguiente:
Código:

procedure TFormAnaglifo.EditBrilloKeyPress(Sender: TObject; var Key: Char);
begin
  if ( StrScan('0123456789.-',Key) <> nil ) or
    ( Key = Char(VK_BACK) ) or ( Key = char(13) ) then { BackSpace Key }
  begin
    if (key = char(13)) and (EditBrillo.Text <> '') then
    begin
      ScrollBarBrillo.Position := StrToInt(EditBrillo.Text);
      EditBrillo.Visible := False;
    end;
  end else
    Key := #0;
end;

Saludos...
Miguel Angel
http://imagen3d.site88.net/

dec 24-08-2008 12:46:23

Hola,

Se ha tratado en estos foros más de una vez. Se trata de averiguar si es la tecla ENTER la que "dispara el evento", y, si es así, retornar en la variable "Key" el valor "0".

madiazg 25-08-2008 21:33:38

Efectivamente, esa era la solución. Simplemente añadiendo Key := #0
Código:

procedure TFormAnaglifo.EditColorRojoKeyPress(Sender: TObject; var Key: Char);
begin
  if ( StrScan('0123456789.-',Key) <> nil ) or
    ( Key = Char(VK_BACK) ) or ( Key = char(13) ) then { BackSpace Key }
  begin
    if (key = char(13)) and (EditColorRojo.Text <> '') then
    begin
      ScrollBarRojo.Position := StrToInt(EditColorrojo.Text);
      EditColorRojo.Visible := False;
      Key := #0;
    end;
  end else
    Key := #0;
end;

Gracias.
Saludos...
Miguel Angel
http://imagen3d.site88.net/


La franja horaria es GMT +2. Ahora son las 10:47:41.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi