Mode Property of MCIWNDX.VBX Returns Localized Strings

Last reviewed: June 21, 1995
Article ID: Q126990
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 3.0 - Microsoft Video for Windows Development Kit, version 1.1

SUMMARY

The MCIWNDX.VBX control distributed with the Video for Windows Development Kit version 1.1, has a Mode property containing a localized string that tells you the current state of the control. When this control is used on versions of Windows other than those that use the English language, such as German or French, the Mode is automatically translated into that language. Because of this feature, you must not use a hard coded string literal when checking the Mode property. As an alternative, you can call the Multimedia API mciSendCommand() function. This article shows you how.

MORE INFORMATION

To determine the state of the MCIWNDX control, you can check the Mode property. However, both the Mode property and the Mode argument to the ModeChange event are represented as localized strings. For example, if the control were playing back a video clip and the Mode property was displayed in the US version of Windows, the word "running" would be displayed. However, in the German version of Windows, the word "Wiedergabe" would be displayed. This makes it impossible to write code like the following that works in all versions of Windows:

   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.

Step-by-Step Example

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the MCIWNDX.VBX to your project.

  3. Create a new Module (Module1) to the project and add the following code to the general declarations section:

    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
    
    

  4. Add the following function to the module:

    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
    
    

  5. Add a command button (Command1) and an MCIWNDX control (MCIWnd1) to Form1.

  6. In the click event of Command1, add this code:

       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
    
    

  7. Press the F5 key to run the program. Click the Command1 button to load CLOCK.AVI into the control and see "stopped" printed on the form.


Additional reference words: 3.00 localize foreign
KBCategory: kbprg kbcode
KBSubCategory: PrgCtrlsCus


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.