Information générale
Catégorie:
Codage, syntaxe et commandes
creat a form and put in:
********************************
*in init
DECLARE INTEGER mciSendString ;
IN WinMM.DLL ;
STRING cMCIString,;
STRING @cRetString,;
INTEGER nRetLength,;
INTEGER hInstance
*!* This function allows us to retrieve the last MCI error that occured
DECLARE INTEGER mciGetErrorString ;
IN WINMM.DLL ;
INTEGER nErrorno, ;
STRING @cBuffer, ;
INTEGER nBufSize
THIS.playmusic()
*******************************
*******************************
*make a method named playmusic and put in it folowing command
LOCAL cFileName
*!* Check to make sure a media file is not already open
IF THISFORM.doMCI("STATUS SoundTest READY") = "true"
*!* It's open so close it
THISFORM.doMCI("CLOSE SoundTest WAIT")
ENDIF
cFileName = SYS(5)+SYS(2003)+"\hotelcal.mid" &&name of music file
THISFORM.doMCI('OPEN "' + cFileName + '" alias SoundTest WAIT')
IF THISFORM.MCIerror > 0
** No music.
RETURN .F.
ENDIF
THISFORM.doMCI("PLAY SoundTest")
*****************************************
*****************************************
*make a method named domci and put in it folowing command
LPARAMETERS cMCIcmd
LOCAL cRetString, cErr, nRetValue
*!* This method takes a MCI command string and executes it using
*!* the Windows API function mciSendString
*!* If the function executes successfully, the result is returned.
*!* Otherwise, the error string is returned.
cRetString = space(80)
nRetValue = mciSendString(cMCIcmd,@cRetString,len(cRetString),0)
cErr = THISFORM.getMCIerror(nRetValue)
IF nRetValue > 0
RETURN CeRR
ENDIF
RETURN TRIM(STRTRAN(cRetString,chr(0),""))
*****************************************
*****************************************
*make a method named getmcierror and put in it folowing command
LPARAMETERS cError
LOCAL lcErrorString, nError
*!* This method is called from the THISFORM.doMCI to retrieve the last
*!* MCI error string.
*!* This function also saves the last error number and string
*!* into properties associated with the form.
nError=0
IF TYPE("cError")="C"
IF LEFT(cError,7)="*ERROR*"
nError=val(substr(cError,8))
ENDIF
ENDIF
IF TYPE("cError")="N"
nError=cError
ENDIF
cErrorString=SPACE(256)
mciGetErrorString(nError,@cErrorString,len(cErrorString))
THISFORM.MCIerror = nError
THISFORM.MCIerrorString = cErrorString
RETURN TRIM(CHRTRAN(cErrorString,CHR(0),""))
*****************************************
*****************************************
*in release method of form put folowing command
*!* Turn Sound off:
IF THISFORM.doMCI("STATUS SoundTest READY") = "true"
** It's open so close it
THISFORM.doMCI("CLOSE SoundTest WAIT")
ENDIF
SET BELL TO
*****************************************
*****************************************
make two properties on your form
1- mcierror=.f.
2- mcierrorstring=.f.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement