Put this code in a module. Also, put a CommandButton and a CheckBox on the Form.
Code:
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Put these 2 functions in the module.
Code:
Public Sub LoadMusic(path As String)
Dim shortPath As String * 128
Dim shortPath2 As String
Dim counter As Integer
Dim chr As String
GetShortPathName path, shortPath, 128
Do Until chr = "."
counter = counter + 1
chr = Mid(shortPath, counter, 1)
Loop
counter = counter + 3
shortPath2 = Mid(shortPath, 1, counter)
mciSendString "open " & shortPath2 & " type sequencer alias background", 0, 0, 0
End Sub
Public Function getMIDIStatus() As Integer
Dim statusString As String * 255
getMIDIStatus = 1
mciSendString "status background mode", ByVal statusString, 255, 0
If Left(statusString, 7) = "playing" Then getMIDIStatus = 0
If Left(statusString, 6) = "paused" Then getMIDIStatus = 0
End Function
Put this in your CommandButton
Code:
Private Sub Command1_CLick()
mciSendString "open C:\MyMidi.mid type sequencer alias background", 0, 0, 0
mciSendString "play background", 0, 0, 0
End Sub
Put this in your CheckBox
Code:
Private Sub Check1_Click()
'Stops the music when the box is checked
If Check1.Value = Checked Then
mciSendString "close background", 0, 0, 0
End If
End Sub
[Edited by Megatron on 05-21-2000 at 09:23 AM]