Ver Mensaje Individual
  #3  
Antiguo 22-10-2012
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Smile

Homero1225,

Revisa este ejemplo:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, MMSystem;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    procedure SoundKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SoundKeyPress(Sender: TObject; var Key: Char);
var
   SoundKey : string;
   i : Integer;

begin

  SoundKey := ExtractFilePath(Application.ExeName) + 'Windows Logon Sound.wav';

  for i := 1 to 3 do
  begin
     // API de Windows Multimedia Sounds en la Unidad MMSystem
     PlaySound(PAnsiChar(SoundKey), 0, SND_FILENAME or SND_ASYNC);
     Sleep(1000);
  end;

  MessageDlg('Key =' + IntToStr(Ord(Key)) + ' has been pressed', mtInformation, [mbOK], 0);

end;

end.
El Evento OnKeyPress del Control TEdit por medio del procedure TForm1.SoundKeyPress reproducira 3 veces seguidas un archivo .WAV con un intervalo de un segundo entre sonido y mostrara el código ASCII de la tecla presionada.

Espero sea útil

Nelson.
Responder Con Cita