Einzelnen Beitrag anzeigen

Benutzerbild von blondervolker
blondervolker

Registriert seit: 14. Sep 2010
Ort: Bei: Leeeiipzzhhh
381 Beiträge
 
Delphi XE2 Architect
 
#6

AW: timer und Playsound

  Alt 12. Sep 2013, 13:35
Und denne in Uses: mmSystem reinbasteln,

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses
  mmSystem;

{$R *.dfm}

procedure PlayMySound(SndName: String); //uses mmSystem
var
  FilePath: String;
begin
  FilePath := ExtractFilePath(ParamStr(0)) + 'Sounds\' + SndName + '.wav';

  if FileExists(FilePath) then
    //SndPlaySound(PAnsiChar(FilePath), SND_ASYNC ); //Alternative
    PlaySound(PChar(FilePath), hInstance, SND_ASYNC or SND_FILENAME);
end;

procedure TForm1.Button1Click(Sender: TObject);
//spielt Sound 1
begin
  PlayMySound('wav1');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
//spielt Sound 2
  PlayMySound('wav2');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
//spielt Sound 3
  PlayMySound('wav3');
end;

end.
www.bewerbungsmaker.de
  Mit Zitat antworten Zitat