18. oktober 2004 - 17:08Der er
3 kommentarer og 1 løsning
afspil lydfil ved form_load
afspil lydfil ved form_load
X Hej alle xperts.
Jeg er i gang med at lave et program til nogle af mine venner. Jeg har noget godt musik jeg godt kunne tænke mig at programmet afspiller når jeg starter det (kunne også godt være ved tryk på knap). Det er en mp3 fil. Jeg mener det skulle være i Private Sub Form_load??????
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Private 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
Private Sub Form_Load() ' Starter din musik Call MCIPlay("D:\din_mpeg3_file.mp3", "Aliasname") End Sub
Private Sub Form_Unload(Cancel As Integer) ' Stopper musikken igen Call MCIStop("Aliasname") End Sub
Public Sub MCIPlay(strFilename As String, strAlias As String) Dim strCommand As String strCommand = "open " & ShortPath(strFilename) & " type MPEGVideo Alias " & strAlias If MCICommand(strCommand) = 0 Then Call MCICommand("play " & strAlias & " from 0") End If End Sub
Public Sub MCIStop(strAlias As String) Call MCICommand("stop " & strAlias) Call MCICommand("close " & strAlias) End Sub
Public Function ShortPath(strFilename As String) As String Dim strNull As String * 255 Dim dwReturn As Long dwReturn = GetShortPathName(strFilename, strNull, 255) If dwReturn Then ShortPath = Left$(strNull, dwReturn) End If End Function
Public Function MCICommand(strCommand As String) As Long MCICommand = mciSendString(strCommand, 0&, 0&, 0&) End Function '------------------------------------------ Form1 ------------------------------------------
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.