home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 February
/
PCWK0297.iso
/
envelop
/
envelop.5
/
Tools
/
Arsenal
/
tools
/
playwav
/
playwav.eto
< prev
next >
Wrap
Text File
|
1996-07-08
|
8KB
|
289 lines
Type SoundPlayerMasterForm From SampleMasterForm
Dim lstWaveFiles As New ListBox
Dim lstSelDirectory As New FileListBox
Dim btnSearch As New Button
Dim btnClear As New Button
Dim cboSelDrive As New FileComboBox
Dim Label1 As New Label
Dim Label2 As New Label
Dim Label3 As New Label
Dim lblCurDirectory As New Label
Dim lblSearchDirectory As New Label
Dim tmrStopWatch As New StopClock
' METHODS for object: SoundPlayerMasterForm
Sub AddFileToList(ByVal path as string, ByVal attr as long)
lstWaveFiles.AddItem path
' Process events to update display and/or Cancel
App.DoEvents()
End Sub
Sub btnClear_Click()
If btnClear.Caption = "Cancel" Then
Throw AbortFlag()
Else
lstWaveFiles.Clear
End If
End Sub
Sub btnSearch_Click()
Dim searchstring As String
Dim file_count As single
Dim total_time As String
' Disable controls until after search
lstWaveFiles.Enabled = 0
lstSelDirectory.Enabled = 0
cboSelDrive.Enabled = 0
btnClear.Caption = "Cancel"
btnSearch.Enabled = "False"
' Clear the wave file list
lstWaveFiles.Clear
tmrStopWatch.Start
' Initiate the recursive search for matching files
Try
GenerateWaveList lstSelDirectory.Path
catch AbortFlag()
InfoBox.Message("", "Search operation cancelled.")
End Try
tmrStopWatch.Finish
total_time = tmrStopWatch.ElapsedTime
tmrStopWatch.Reset
' Disable controls until after search
lstWaveFiles.Enabled = -1
lstSelDirectory.Enabled = -1
cboSelDrive.Enabled = -1
btnClear.Caption = "Clear"
btnSearch.Enabled = "True"
file_count = lstWaveFiles.ListCount
InfoBox.Message("", file_count & " sound files located in " & total_time & " time.")
End Sub
Sub cboSelDrive_Click()
' Set the path for the Select Directory list
lstSelDirectory.Path = cboSelDrive.SelPath
' Update the Search Directory label
lblCurDirectory.Caption = lstSelDirectory.Path
End Sub
Sub ExitApplication_Click()
Dim F Strictly As SampleMasterForm
F = Me
' Set the contents of the titlebar of the YesNoPrompt object
YesNoBox.title = "Quit?"
' Set the message of the YesNoPrompt object
YesNoBox.Msg("Ok to quit application?")
' If the Yes entry was clicked, hide the textedit form
If YesNoBox.result = 6 Then
' Forward to parent
F.ExitApplication_Click
End If
End Sub
Sub GenerateWaveList(ByVal searchFrom As String)
Dim dir As New Directory
dir.Path = IIf(searchFrom <> "", searchFrom, dir.CurrentDir)
dir.EnumContents(Me, "AddFileToList", "*.wav", True)
End Sub
Sub Load()
' Restore prerequisite objects that are shared with other
' samples, and therefore may already be loaded.
If FindObject("AudioPlayer") = Nothing Then
LoadTextObject(SampleDir & "audio.eto")
End If
End Sub
Sub lstSelDirectory_DblClick()
' Set the Select Directory path to the one chosen
lstSelDirectory.Path = lstSelDirectory.SelPath
' Update the Search Directory label
lblCurDirectory.Caption = lstSelDirectory.Path
End Sub
Sub lstWaveFiles_Click()
Dim option As long
Dim result As long
Dim sound_file As String
' Set a variable to be the name of sound file including absolute path
sound_file = lstWaveFiles.Text
' Play the selected sound file
result = AudioPlayer.sndPlaySoundA(sound_file, option)
End Sub
Sub ResetApplication_Click()
' Preset the height of the combo drive box
cboSelDrive.Height = 1500
' Initialize the Search Directory label
lblCurDirectory.Text = lstSelDirectory.Path
' Preset the combo drive box
cboSelDrive.SelectDrive(lstSelDirectory.Path)
End Sub
Sub Resize()
Dim min_width As single
Dim min_height As single
Dim edge_margin As single
Dim gap_margin As single
edge_margin = 200
gap_margin = 200
min_height = 4000
min_width = 6500
If SoundPlayerMasterForm.Width < min_width Then
SoundPlayerMasterForm.Width = min_width
End If
If SoundPlayerMasterForm.Height < min_height Then
SoundPlayerMasterForm.Height = min_height
End If
lstWaveFiles.Width = SoundPlayerMasterForm.ScaleWidth - lstWaveFiles.Left - edge_margin
btnClear.Left = SoundPlayerMasterForm.ScaleWidth - btnClear.Width - edge_margin
btnSearch.Left = btnClear.Left - btnSearch.Width - gap_margin
lblCurDirectory.Width = btnSearch.Left - gap_margin - lblCurDirectory.Left
btnClear.Top = SoundPlayerMasterForm.ScaleHeight - edge_margin - btnClear.Height
lstWaveFiles.Height = btnClear.Top - gap_margin - lstWaveFiles.Top
btnSearch.Top = btnClear.Top
lblCurDirectory.Top = btnClear.Top
lblSearchDirectory.Top = lblCurDirectory.Top - lblSearchDirectory.Height
lstSelDirectory.Height = lstWaveFiles.Height - (lstSelDirectory.Top - lstWaveFiles.Top)
SoundPlayerMasterForm.Refresh
End Sub
End Type
Type AudioPlayer
Dim SND_SYNC As Long
Dim SND_ASYNC As Long
Dim SND_NODEFAULT As Long
Dim SND_MEMORY As Long
Dim SND_LOOP As Long
Dim SND_NOSTOP As Long
Declare Function sndPlaySoundA Lib "Winmm" (ByVal file As String, ByVal opt As Long) As Long
' METHODS for object: AudioPlayer
Function Play(file As String) As Long
Play = sndPlaySoundA(file, SND_ASYNC Or SND_NODEFAULT)
End Function
Function PlaySync(file As String) As Long
Play = sndPlaySoundA(file, SND_SYNC Or SND_NODEFAULT)
End Function
End Type
Begin Code
' Reconstruction commands for object: SoundPlayerMasterForm
'
With SoundPlayerMasterForm
.Caption := "Sound Player"
.Move(3840, 1170, 8955, 4980)
.Parent := EnvelopForm
.SampleDir := "C:\ENVELOP\arsenal\tools\playwav\"
.SampleName := "PLAYWAV"
With .lstWaveFiles
.Caption := "lstWaveFiles"
.ZOrder := 1
.Move(2475, 450, 6165, 2910)
End With 'SoundPlayerMasterForm.lstWaveFiles
With .lstSelDirectory
.Caption := "lstSelDirectory"
.ZOrder := 2
.Move(270, 1420, 1875, 1950)
.ShowDirs := True
.ShowFiles := False
End With 'SoundPlayerMasterForm.lstSelDirectory
With .btnSearch
.Caption := "Search"
.ZOrder := 3
.Move(6635, 3760, 900, 330)
End With 'SoundPlayerMasterForm.btnSearch
With .btnClear
.Caption := "Clear"
.ZOrder := 4
.Move(7735, 3760, 900, 330)
End With 'SoundPlayerMasterForm.btnClear
With .cboSelDrive
.ZOrder := 5
.Move(300, 450, 1875, 360)
.ShowDrives := True
.ShowFiles := False
End With 'SoundPlayerMasterForm.cboSelDrive
With .Label1
.Caption := "Drives:"
.ForeColor := 13107200
.ZOrder := 6
.Move(150, 150, 750, 240)
End With 'SoundPlayerMasterForm.Label1
With .Label2
.Caption := "Directories:"
.ForeColor := 13107200
.ZOrder := 7
.Move(150, 1035, 1500, 240)
End With 'SoundPlayerMasterForm.Label2
With .Label3
.Caption := "Sound Files: (Click to play)"
.ForeColor := 13107200
.ZOrder := 8
.Move(2325, 150, 2880, 240)
End With 'SoundPlayerMasterForm.Label3
With .lblCurDirectory
.Caption := "C:\envelop"
.ZOrder := 9
.Move(300, 3760, 6135, 300)
End With 'SoundPlayerMasterForm.lblCurDirectory
With .lblSearchDirectory
.Caption := "Search Directory:"
.ForeColor := 13107200
.ZOrder := 10
.Move(150, 3460, 1950, 300)
End With 'SoundPlayerMasterForm.lblSearchDirectory
With .tmrStopWatch
End With 'SoundPlayerMasterForm.tmrStopWatch
With .helpfile
.FileName := "C:\ENVELOP\arsenal\tools\playwav\PLAYWAV.hlp"
End With 'SoundPlayerMasterForm.helpfile
End With 'SoundPlayerMasterForm
' Reconstruction commands for object: AudioPlayer
'
With AudioPlayer
.SND_SYNC := 0
.SND_ASYNC := 1
.SND_NODEFAULT := 2
.SND_MEMORY := 4
.SND_LOOP := 8
.SND_NOSTOP := 16
End With 'AudioPlayer
End Code