Microsoft KB Archive/142389

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

Article ID: 142389

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q142389



This article shows by example 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
The example uses the mciSendString application programming interface (API) from Microsoft Windows version 3.1 or Microsoft Windows version 3.0 with Multimedia Extensions.

For the example to work, your computer must be able to play .AVI files and you need either Microsoft Windows version 3.1 or Microsoft Windows version 3.0 with Multimedia Extensions.

The .AVI file included in the example (WNDSURF1.AVI) is the one from Microsoft Video for Windows.

Information in the Visual Basic 4.0 section applies only to Visual Basic 4.0, and information in the Visual Basic 3.0 section applies only to Visual Basic 3.0.

Step-by-Step Example
 Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. Add a command button (Command1) to Form1, and set its caption property to: Play Video.  Add the following line of code to the (general) (declarations) section of Form1: #If Win32 Then

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 #Else Private Declare Function mciSendString Lib "mmsystem" (ByVal _  lpstrCommand As String, ByVal lpstrReturnStr As Any, ByVal _   wReturnLen As Integer, ByVal hCallBack As Integer) As Long #End If

  Add the following lines of code to the Command1 Click event procedure: Sub Command1_Click CmdStr$ = "play c:\winvideo\wndsurf1.avi fullscreen " ReturnVal& = mciSendString(CmdStr$, 0&, 0, 0&) End Sub

 From the Run menu, choose Start (ALT, R, S) to run the program.

Click the Play Video button to watch the video full screen. The video will last for a few seconds and return back to the Visual Basic environment.

Step-by-Step Example
 Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.</li> Add a command button (Command1) to Form1, and set its caption property to: Play Video.</li>  Add the following line of code to the (general) (declarations) section of Form1: ' Enter the following Declare statement on one, single line:

Declare Function mciSendString Lib "mmsystem" (ByVal lpstrCommand$,  ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal hCallBack%) As   Long

</li>  Add the following lines of code to the Command1 Click event procedure: Sub Command1_Click CmdStr$ = "play c:\winvideo\wndsurf1.avi fullscreen " ReturnVal& = mciSendString(CmdStr$, 0&, 0, 0&) End Sub

</li> From the Run menu, choose Start (ALT, R, S) to run the program.</li></ol>

Click the Play Video button to watch the video full screen. The video will last for a few seconds and return back to the Visual Basic environment.

Additional query words: 1.00 2.00 3.00 4.00 vb4win vb4all

Keywords: kbcode KB142389

-

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

© Microsoft Corporation. All rights reserved.