tvplanit: Use OnPlaySound event in TWavDlg (basic functionality)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4738 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-13 12:57:00 +00:00
parent d22805889a
commit 7ae8dc2155
2 changed files with 37 additions and 33 deletions

View File

@ -125,11 +125,15 @@ type
StartTime: TComboBox;
EndTime: TComboBox;
{$ENDIF}
FDatastore: TVpCustomDatastore;
AAVerifying: Boolean;
CIVerifying: Boolean;
FCustomInterval : TVpRightAlignedEdit;
procedure PopLists;
procedure LoadCaptions;
procedure DoPlaySound(Sender: TObject; const AWavFile: String; AMode: TVpPlaySoundMode);
protected
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
public { Public declarations }
Event: TVpEvent;
CatColorMap: TVpCategoryColorMap;
@ -656,8 +660,32 @@ end;
{=====}
procedure TDlgEventEdit.SoundFinderBtnClick(Sender: TObject);
var
SoundFinder: TfrmSoundDialog;
begin
ExecuteSoundFinder(AlarmWavPath);
Application.CreateForm(TfrmSoundDialog, SoundFinder);
try
SoundFinder.DingPath := AlarmWavPath;
SoundFinder.Populate;
SoundFinder.ShowModal;
SoundFinder.OnPlaySound := DoPlaySound;
if SoundFinder.ReturnCode = TvpEditorReturnCode(rtCommit) then begin
if SoundFinder.CBDefault.Checked then
AlarmWavPath := ''
else
AlarmWavPath := SoundFinder.FileListBox1.FileName;
end;
finally
SoundFinder.Release;
end;
end;
{=====}
procedure TDlgEventEdit.DoPlaySound(Sender: TObject; const AWavFile: String;
AMode: TVpPlaySoundMode);
begin
if DataStore <> nil then
Datastore.PlaySound(AWavFile, AMode);
end;
{=====}
@ -688,6 +716,7 @@ begin
try
DoFormPlacement(DlgEventEdit);
SetFormCaption(DlgEventEdit, Event.Description, RSDlgEventEdit);
DlgEventEdit.Datastore := Datastore;
DlgEventEdit.Event := Event;
DlgEventEdit.TimeFormat := FTimeFormat;
DlgEventEdit.Resource := DataStore.Resource;

View File

@ -71,20 +71,18 @@ type
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
FOnPlaySound: TVpPlaySoundEvent;
public
DingPath: string;
ReturnCode : TVpEditorReturnCode;
procedure Populate;
property OnPlaySound: TVpPlaySoundEvent read FOnPlaySound write FOnPlaySound;
end;
function ExecuteSoundFinder(var DingPath: string): Boolean;
implementation
uses
{$IFNDEF LCL}
mmSystem,
{$ENDIF}
VpSR;
{$IFDEF LCL}
@ -93,29 +91,6 @@ uses
{$R *.dfm}
{$ENDIF}
function ExecuteSoundFinder(var DingPath: string): Boolean;
var
SoundFinder: TfrmSoundDialog;
begin
Result := false;
Application.CreateForm(TfrmSoundDialog, SoundFinder);
try
SoundFinder.DingPath := DingPath;
SoundFinder.Populate;
SoundFinder.ShowModal;
if SoundFinder.ReturnCode = rtCommit then begin
if SoundFinder.CBDefault.Checked then
DingPath := ''
else
DingPath := SoundFinder.FileListBox1.FileName;
Result := true;
end;
finally
SoundFinder.Release;
end;
end;
{=====}
procedure TFrmSoundDialog.FileListBox1Change(Sender: TObject);
begin
if FileListBox1.Items.Count > 0 then begin
@ -130,11 +105,11 @@ end;
procedure TFrmSoundDialog.PlayButtonClick(Sender: TObject);
begin
PlayButton.Enabled := false;
{$IFNDEF LCL}
SndPlaySound(PChar(FileListBox1.FileName), snd_Sync);
{$ENDIF}
PlayButton.Enabled := true;
if Assigned(FOnPlaySound) then begin
PlayButton.Enabled := false;
FOnPlaySound(self, FileListbox1.FileName, psmSync);
PlayButton.Enabled := true;
end;
end;
{=====}