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 106 107 108 109
|
Private Sub Form_Current()
'L'évènement activation (current) se produit lorsque le focus passe à un enregistrement
' donné pour en faire l'enregistrement en cours ou lorsque le formulaire est
' Actualisé ou en Actualisation
'si le nom du salarié est non vide : on visualise un enregistrement
' sinon cela indique que nous sommes sur un environnement vierge, donc en cours de saisie.
' Me.Caption : gère le titre du formulaire
If Len(Me.NOMPHOTOS) > 0 Then
Me.Caption = "PHOTOS: " & Me.NOMPHOTOS & Me.DATE & Me.OCCASION
Else
Me.Caption = "Saisie d'une nouvelle photo"
End If
'Gestion des erreurs
On Error GoTo Catch02
'si la photo n'est pas définie, on affiche la photo ballade_menhir_2
'CurrentProject.Path : est le chemin de l'application
If Len(Me.Photo) > 0 Then
Me.imgPhoto.Picture = Me.Photo
Else
Me.imgPhoto.Picture = CurrentProject.Path & "\Mes_images\BLANK"
End If
DisplayPhoto
Exit Sub
Catch02
Select Case Err.Number
Case 2114
'Cas d'un type de fichier photo non supporté
' on sort de la procédure
MsgBox "Le format de l'image n'est pas supporté par le contrôle image picture", vbCritical + vbOKOnly, "Application photos"
Exit Sub
Case 2220
'Cas d'un emplacement non valide du fichier image
MsgBox "Le fichier image n'a pas été trouvé à l'emplacement indiqué:" & vbCrLf & _
Me.Photo, vbCritical + vbOKOnly, "Application Photo"
Exit Sub
Case Else
'tout autre cas d'erreur
MsgBox "Erreur inattendue : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Application photos"
End Select
Err.Clear
End Sub
Private Sub CmdDelete_Click()
'Bouton de commande d'effacement de la photo
'supprime l'adresse de la photo
Me.Photo = vbNullString
'affiche l'image ballade_menhir_2.jpg
Me.imgPhoto.Picture = CurrentProject.Path & "\images\blank.jpg"
'redimensionne la photo
DisplayPhoto
End Sub
Private Sub CmdPhoto_Click()
'Bouton d'ajout - modification de photo
Dim StrLink As String
'Gestion des erreurs
On Error GoTo Catch01
'récupération du chemin physique de la photo
'par la boîte de dialogue
StrLink = OuvrirUnFichier(Me.Hwnd, _
"selectionner une photo pour la photo" & Me.NOMPHOTOS, _
1)
'si la boîte renvoie une adresse non nulle
If Len(StrLink) > 0 Then
'tentative d'affichage de la photo
Me.imgPhoto.pictures = StrLink
Me.Photo = StrLink
End If
Display Photo
Exit Sub
Catch01:
Select Case Err.Number
Case 2114
'Cas d'un type de photo non supporté ...
' on sort de la procédure
MsgBox "Le format de l'image n'est pas supoporté par le contrôle image Picture", vbCritical + vbOKOnly, "Application Photos"
Exit Sub
Case 2220
'Cas d'un emplacement non valide du fichier image
MsgBox "Le fichier image n'a pas été trouvé à l'emplacement indiqué : " & vbCrLf & _
Me.Photo, vbCritical + vbOKOnly, "Applications Photos"
Exit Sub
Case Else
'tout autre cas d'erreur
MsgBox "Erreur inattendue : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Application Photos"
End Select
Err.Clear
End Sub |
Partager