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
|
'### GESTION DU CLIC DANS LA LISTVIEW2
Private Sub ListView2_Click()
Dim Chemin As String, Fichier As String, FichierTemp As String, TitreFichier As String, FilmSelection As String
Dim Fs As FileSystemObject, Dossier As Folder, F As File, Img As Object, IP As Object
Dim Cpt As Integer, LstItem As ListItem
With ListView2
On Error Resume Next 'Si aucune ligne est sélectionnée dans la listview on sort
Set LstItem = .SelectedItem
On Error GoTo 0
If LstItem Is Nothing Then Exit Sub
FilmSelection = .ListItems.Item(.SelectedItem.Index)
Label25 = FilmSelection 'Affiche le nom du film sélectionné dans le label 25
Chemin = "E:\Videos\"
Fichier = "E:\Affiche\" & FilmSelection & ".jpg"
Set Fs = CreateObject("Scripting.FileSystemObject")
Set Dossier = Fs.GetFolder("E:\Affiche")
For Each F In Dossier.Files
If F.Name = FilmSelection & ".jpg" Then Cpt = 1
Next
'DIMENSIONNEMENT DE L'IMAGE POUR QU'ELLE ENTRE DANS L'USERFORM imageFilm
Set Img = CreateObject("WIA.ImageFile") 'Création conteneur pour l'image à manipuler
Set IP = CreateObject("WIA.ImageProcess") 'Création du gestionnaire de filtre
Fichier = IIf(Cpt = 0, "E:\Affiche\Liberty.jpg", Fichier) 'Si l'affiche n'existe pas on prend l'affiche Liberty.jpg par défaut
Img.LoadFile Fichier 'Chargement de l'image dans le conteneur
IP.Filters.Add IP.FilterInfos("Scale").FilterID 'Ajoute le filtre pour redimensionner l'image (Scale)
IP.Filters(1).Properties("MaximumWidth") = 315 'Définit la largeur maxi pour le redimensionnement
IP.Filters(1).Properties("MaximumHeight") = 375 'Définit la hauteur maxi pour le redimensionnement
IP.Filters(1).Properties("PreserveAspectRatio") = False 'Ne garde pas les proportions
Set Img = IP.Apply(Img) 'Application du filtre à l'image
FichierTemp = "E:\Affiche\temp$$$$.jpg" 'Crée une image temporaire pour l'afficher dans l'userform imageFilm
'Donne un nom (temp$$$$.jpg) dont on est sûr qu'il n'est et ne sera pas utilisé
On Error Resume Next
Kill FichierTemp 'Supprime l'image temp$$$$.jpg si elle existe
On Error GoTo 0
Img.SaveFile FichierTemp 'Sauvegarde le fichier
TitreFichier = Split(IIf(Cpt = 0, "Liberty.jpg", FilmSelection & ".jpg"), ".")(0)
With imageFilm
.Show
.Caption = TitreFichier
.Picture = LoadPicture(FichierTemp)
End With
Kill FichierTemp 'Suppression de l'image temp$$$$.jpg en fin de macro
'### Appel du film choisi dans la Listview2
LecteurWindowsMedia.Show
End With
End Sub
Private Sub ListView2_ItemCheck(ByVal Item As MSComctlLib.ListItem)
With ListView2
.ListItems(Item.Index).Selected = True
For i = 1 To .ListItems.Count
If i <> Item.Index Then .ListItems(i).Checked = False
Next i
End With
End Sub
Private Sub ListView2_ItemClick(ByVal Item As MSComctlLib.ListItem)
Item.Checked = True
With ListView2
For i = 1 To .ListItems.Count
If i <> Item.Index Then .ListItems(i).Checked = False
Next i
End With
End Sub |