Microsoft KB Archive/171981

= How To Play an .AVI Video File in Full Screen in Visual Basic =

Article ID: 171981

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q171981



SUMMARY
This article demonstrates how to play an .AVI (video) file in full screen from Visual Basic for Windows. When you play an .AVI file using the full screen, the color palette focus is set to the .AVI file only. No dithering of colors occurs because there are no other windows in the background to capture the color palette.



MORE INFORMATION
This example uses the mciSendString application programming interface (API). Your computer must be able to play .AVI files for this sample to work.

Step-by-Step Example
 Create a new Visual Basic Standard Exe project. Add a CommandButton (Command1) to Form1, and set its Caption property to "Play Video."  Add the following line of code to the General Declarations section of Form1: Private Declare Function mciSendString Lib "winmm.dll" Alias _ "mciSendStringA" (ByVal lpstrCommand As String, ByVal _       lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _        hwndCallback As Long) As Long

  Add the following lines of code to the Command1 Click event procedure: Sub Command1_Click '// --- Modify FILE_TO_OPEN constant as appropriate --- Const FILE_TO_OPEN = "C:\winnt\clock.avi" Dim strCmdStr As String Dim lngReturnVal As Long strCmdStr = "play " & FILE_TO_OPEN & " fullscreen " lngReturnVal = mciSendString(strCmdStr, 0&, 0, 0&) End Sub

 Press the F5 key to execute the sample code. Click the Play Video button to watch the video full screen. The video will last for a few seconds and then return to the Visual Basic environment.</ol>

Keywords: kbhowto kbapi KB171981

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.