Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing movies in VB6

Status
Not open for further replies.

cyberwolf14

Programmer
Aug 27, 2001
65
0
0
BE
Hello,

Does anyone know how to play movies from a vb application. But I want the movies to be imported if i create the appliction, so the movie is in the appliction and i would like to let it play from there.
 
How about shelling out to Windows Media Player and making your program the parent form?

Check out this example using notepad:

--------------------------------------------------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long

Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
'Find the first window
test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While test_hwnd <> 0
'Check if the window isn't a child
If GetParent(test_hwnd) = 0 Then
'Get the window's thread
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
'retrieve the next window
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function

Private Sub Form_Load()
'KPD-Team 1999
'URL: 'E-Mail: KPDTeam@Allapi.net
Dim Pid As Long
'Lock the window update
LockWindowUpdate GetDesktopWindow
'Execute notepad.Exe
Pid = Shell(&quot;c:\windows\notepad.exe&quot;, vbNormalFocus)
If Pid = 0 Then MsgBox &quot;Error starting the app&quot;
'retrieve the handle of the window
mWnd = InstanceToWnd(Pid)
'Set the notepad's parent
SetParent mWnd, Me.hwnd
'Put the focus on notepad
Putfocus mWnd
'Unlock windowupdate
LockWindowUpdate False
End Sub

Private Sub Form_Unload(Cancel As Integer)
'Unload notepad
DestroyWindow mWnd
'End this program
TerminateProcess GetCurrentProcess, 0
End Sub
----------------------------------------------
 
This is not exactly what i want.

I just want to import a movie in my project like you import an object in OLE. then I just want to play that movie
 
You can play AVIs using either a form or a picturebox as the screen. Code for this can be found at


The code is for a picturebox but can be adapted for an entire form. I don't know if you can do other movie types though, and the code doesn't allow for the movie to be halted, so until it has finished playing you can't quit the program.
 
You can't import the movie file into your project - it will have to be a separate file.

The easiest way is to use the ActiveX Windows Media Player control - no programming required.

HTH,

Ed Metcalfe.
 
No, this is not what i mean.

If I put for example a picture in a vb aplication, the picture is in the appliction, I want to do the same with a movie.

Is this possible??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top