1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| Option Explicit
'pour recuperer les dimensions de la fenêtre AVI
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type MCI_OVLY_RECT_PARMS
dwCallback As Long
rc As RECT
End Type
Private Const MCI_WHERE = &H843
Private Const MCI_OVLY_WHERE_SOURCE = &H20000
Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" ( _
ByVal wDeviceID As Long, _
ByVal uMessage As Long, _
ByVal dwParam1 As Long, _
ByRef dwParam2 As Any _
) As Long
Dim Retval&, Buffer$
Dim dwParam2 As MCI_OVLY_RECT_PARMS
Dim LongSupport As Long
Private Sub Form_Load()
'pour disposer du control MCI "MMControl", dans l'editeur VB
'Ctrl + T, choisir dans la fenêtre des composants
'Contrôle Microsoft Multimedia 6.0 =>(MCI32.ocx)
Me.ScaleMode = vbPixels
Me.AutoRedraw = True
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
Picture1.Visible = False
Picture1.BorderStyle = 0
'initialisation des parametres pour jouer le fichier AVI
MMControl1.Visible = False
MMControl1.hWndDisplay = Picture1.hWnd 'fenêtre de sortie pour joué le fichier AVI
MMControl1.DeviceType = "AVIVideo"
MMControl1.FileName = "C:\WINNT\clock.avi" '********** à adapter ********
On Error Resume Next
MMControl1.Wait = True
MMControl1.Command = "Open"
DoEvents
LongSupport = 0
If MMControl1.Length = 0 Or Err.Number <> 0 Then
Err.Clear
MsgBox "impossible d'ouvrire le fichier", vbInformation
Else
recupDim
LongSupport = MMControl1.Length
End If
End Sub
Private Sub Command1_Click()
'bouton de declanchement de l'impression
'remplissage des données dans l'ojet Printer
' ...............
'juste avant l'envoi des données à l'imprimante
If LongSupport <> 0 Then
MMControl1.Command = "Prev" 'recalage à la premiére image
MMControl1.Command = "play"
Picture1.Visible = True
Picture1.Refresh
End If
'envoi des données a l'imprimante
Printer.EndDoc
'ne reprendra le cour du programme que quand les données sont dans
'le spooleur de l'imprimante
If LongSupport <> 0 Then
'cacher le picture et arreter de jouer le fichier AVI
Picture1.Visible = False
MMControl1.Command = "Stop"
End If
End Sub
Private Sub MMControl1_Done(NotifyCode As Integer)
If MMControl1.Position = LongSupport Then
'detection de la fin de lecture du fichier AVI pour le relancer en boucle
MMControl1.Command = "Prev": DoEvents ' retour au debut
MMControl1.Command = "Play" ' rejoue le fichier
End If
End Sub
Public Sub recupDim()
'recuperation des dimenssions de la fenêtre de l'avi
dwParam2.dwCallback = MMControl1.hWnd
dwParam2.rc.Left = 0
dwParam2.rc.Top = 0
dwParam2.rc.Right = 0
dwParam2.rc.Bottom = 0
Retval& = mciSendCommand(MMControl1.DeviceID, MCI_WHERE, MCI_OVLY_WHERE_SOURCE, dwParam2)
DoEvents
If Retval& = 0 Then
'redefinit les dimensions du PictureBox
Picture1.Width = dwParam2.rc.Right
Picture1.Height = dwParam2.rc.Bottom
End If
End Sub |