Option Explicit
Implements CAsso
Private Parent As ControlsAssociés, WithEvents Img As MSForms.Image, Index As Long, _
Colonne As Long, Dossier As String, UsMode, RéfFic As String, Conteneur As Object
Private Sub CAsso_Init(ByVal Lui As ControlsAssociés, ByVal Ctl As MSForms.IControl, ByVal Idx As Long, _
ByVal Col As Long, ByVal Fmt As String, ByVal Mode As Variant)
Dim ImOBn As MSForms.OptionButton, CAssoOBn As CAssoOBn
Set Parent = Lui: Set Img = Ctl: Index = Idx: Colonne = Col: UsMode = Mode
Dossier = Fmt
Set Conteneur = Ctl.Parent
End Sub
Private Function CAsso_Ctl() As MSForms.IControl
Set CAsso_Ctl = Img
End Function
Private Function CAsso_Index() As Long
CAsso_Index = Index
End Function
Private Function CAsso_Col() As Long
CAsso_Col = Colonne
End Function
Private Function CAsso_Format() As String
CAsso_Format = Dossier
End Function
Private Function CAsso_Mode() As Variant
CAsso_Mode = UsMode
End Function
Private Property Let CAsso_Valeur(ByVal RHS As Variant)
On Error Resume Next
If Dossier <> "" And RHS <> "" Then
Img.Picture = LoadPicture(Dossier & "\" & RHS)
Else
Img.Picture = LoadPicture(RHS)
End If
If Err = 0 Then RéfFic = RHS Else MsgBox RHS & vbLf & Err.Description, vbExclamation, "Image"
Conteneur.Repaint
End Property
Private Property Get CAsso_Valeur() As Variant
CAsso_Valeur = RéfFic
End Property
Private Sub Img_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim GOFn
If Button = 1 Then
If Dossier <> "" Then ChDrive Dossier: ChDir Dossier
GOFn = Application.GetOpenFilename("Image,*.jpg;*.gif;*.bmp")
If VarType(GOFn) <> vbString Then Exit Sub
If Dossier <> "" Then If Left$(GOFn, Len(Dossier) + 1) <> Dossier & "\" Then MsgBox _
"Image non rattachée au dossier :" & vbLf & Dossier, vbCritical, "Image" _
Else CAsso_Valeur = Mid$(GOFn, Len(Dossier) + 2) Else CAsso_Valeur = GOFn
ElseIf Button = 2 Then
If CAsso_Valeur = "" Then Exit Sub
If MsgBox("Voulez-vous effacer cette image ?", vbYesNo, "Clic droit") = vbNo Then Exit Sub
CAsso_Valeur = ""
End If
Parent.CAM_Change Me
End Sub