diff --git a/components/tvplanit/source/vpbase.pas b/components/tvplanit/source/vpbase.pas index 56fdee706..20b9cc438 100644 --- a/components/tvplanit/source/vpbase.pas +++ b/components/tvplanit/source/vpbase.pas @@ -72,7 +72,7 @@ type TVpTimeFormat = (tf24Hour, tf12Hour); - TVpPlaySoundMode = (psmSync, psmASync); + TVpPlaySoundMode = (psmSync, psmAsync, psmStop); { XML definitions } DOMString = WideString; diff --git a/components/tvplanit/source/vpbaseds.pas b/components/tvplanit/source/vpbaseds.pas index 45cc4552c..7f09c1c77 100644 --- a/components/tvplanit/source/vpbaseds.pas +++ b/components/tvplanit/source/vpbaseds.pas @@ -892,7 +892,8 @@ begin {$IFDEF WINDOWS} case APlaySoundMode of psmSync : SndPlaySound(PChar(AWavFile), SND_SYNC); - psmASync : SndPlaySound(PChar(AWavFile), SND_ASYNC); + psmAsync : SndPlaySound(PChar(AWavFile), SND_ASYNC); + psmStop : SndPlaySound(nil, 0); end; {$ENDIF} end; diff --git a/components/tvplanit/source/vpwavdlg.lfm b/components/tvplanit/source/vpwavdlg.lfm index 57e76aaa8..44db520ce 100644 --- a/components/tvplanit/source/vpwavdlg.lfm +++ b/components/tvplanit/source/vpwavdlg.lfm @@ -102,6 +102,7 @@ object FrmSoundDialog: TFrmSoundDialog Caption = 'OkBtn' Default = True ModalResult = 1 + OnClick = OkBtnClick TabOrder = 0 end object CancelBtn: TButton @@ -113,6 +114,7 @@ object FrmSoundDialog: TFrmSoundDialog Cancel = True Caption = 'CancelBtn' ModalResult = 2 + OnClick = CancelBtnClick TabOrder = 1 end end diff --git a/components/tvplanit/source/vpwavdlg.pas b/components/tvplanit/source/vpwavdlg.pas index 415df892d..ddc6ca6fe 100644 --- a/components/tvplanit/source/vpwavdlg.pas +++ b/components/tvplanit/source/vpwavdlg.pas @@ -62,12 +62,16 @@ type CBDefault: TCheckBox; OkBtn: TButton; CancelBtn: TButton; + procedure CancelBtnClick(Sender: TObject); procedure CBDefaultClick(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure OkBtnClick(Sender: TObject); procedure PlayButtonClick(Sender: TObject); private FOnPlaySound: TVpPlaySoundEvent; function FindFileItem(AFilename: String): TListItem; + procedure PlaySound; + procedure StopSound; public DingPath: string; MediaFolder: String; @@ -88,6 +92,11 @@ uses {$R *.dfm} {$ENDIF} +procedure TFrmSoundDialog.CancelBtnClick(Sender: TObject); +begin + StopSound; +end; + procedure TFrmSoundDialog.CBDefaultClick(Sender: TObject); begin ShellTreeview.Visible := not CBDefault.Checked; @@ -126,17 +135,24 @@ begin Result := ''; end; +procedure TFrmSoundDialog.OkBtnClick(Sender: TObject); +begin + StopSound; +end; + procedure TFrmSoundDialog.PlayButtonClick(Sender: TObject); begin DingPath := GetSelectedFileName; - if Assigned(FOnPlaySound) then begin - PlayButton.Enabled := false; - FOnPlaySound(self, DingPath, psmSync); - PlayButton.Enabled := true; - end; + PlaySound; end; {=====} +procedure TFrmSoundDialog.PlaySound; +begin + if Assigned(FOnPlaySound) then + FOnPlaySound(self, DingPath, psmAsync); +end; + procedure TFrmSoundDialog.Populate; begin TabSheet1.Caption := RSSelectASound; @@ -160,5 +176,11 @@ begin end; {=====} +procedure TFrmSoundDialog.StopSound; +begin + if Assigned(FOnPlaySound) then + FOnPlaySound(self, '', psmStop); +end; + end.