Article ID: 126990
Article Last Modified on 10/28/2003
If MCIWnd1.Mode = "playing" Then
...
End If
The solution is to use the multimedia API mciSendCommand() function to get
the current mode of the MCI device associated with the MCIWndx control. The
mciSendCommand() function returns the state of the device as a number
instead of a string. The numbers returned by mciSendCommand are constant
across all versions of Windows. An example of calling mciSendCommand is
shown below.
Global Const MCI_STATUS = &H814
Global Const MCI_STATUS_ITEM = &H100&
Global Const MCI_STATUS_MODE = &H4&
Global Const MCI_STRING_OFFSET = 512
Global Const MCI_MODE_NOT_READY = (MCI_STRING_OFFSET + 12)
Global Const MCI_MODE_STOP = (MCI_STRING_OFFSET + 13)
Global Const MCI_MODE_PLAY = (MCI_STRING_OFFSET + 14)
Global Const MCI_MODE_RECORD = (MCI_STRING_OFFSET + 15)
Global Const MCI_MODE_SEEK = (MCI_STRING_OFFSET + 16)
Global Const MCI_MODE_PAUSE = (MCI_STRING_OFFSET + 17)
Global Const MCI_MODE_OPEN = (MCI_STRING_OFFSET + 18)
Type MCI_STATUS_PARMS
dwCallback As Long
dwReturn As Long
dwItem As Long
dwTrack As Long
End Type
' Enter the following declaration as one, single line:
Declare Function mciSendCommand Lib "mmsystem"
(ByVal udeviceid As Integer, ByVal uMessage As Integer,
ByVal dwParam1 As Long, dwParam2 As Any) As Long
Function GetMCIWndxMode (MCIControl As MCIWnd) As Long
Dim Info As MCI_STATUS_PARMS
Dim Ret As Long
Info.dwItem = MCI_STATUS_MODE
Info.dwCallback = 0
Info.dwTrack = 0
' Enter the following two lines as one, single line:
Ret =
mciSendCommand(MCIControl.DeviceID,MCI_STATUS,MCI_STATUS_ITEM,Info)
GetMCIWndxMode = Info.dwReturn
End Function
Sub Command1_Click ()
Dim status As Long
' Load an AVI file into the control:
MCIWnd1.Filename = "c:\winnt35\clock.avi"
' Get the status:
status = GetMCIWndxMode(MCIWnd1)
If status = MCI_MODE_STOP Then ' is it playing or stopped
Print "stopped"
End If
End Sub
Additional query words: 3.00 localize foreign
Keywords: KB126990