Option Explicit
Option Base 1
Public WithEvents CText As MSForms.TextBox
Public WithEvents CCombo As MSForms.ComboBox
Public WithEvents CImg As MSForms.Image
Public WithEvents CCbx As MSForms.CheckBox
Public WithEvents CBtn As MSForms.CommandButton
Public WithEvents CLbl As MSForms.Label
Public WithEvents CFr As MSForms.Frame
Public WithEvents CUF As MSForms.UserForm
Public WithEvents Forme As UserForm
Dim Mctl() As New FWCUF
'Procédure de détection du type de controles
Sub Collection_Ctl(uf, Ctls As MSForms.Control, Optional Transformation As Byte = 0)
Dim hWnd As Long
ReDim Preserve Mctl(Nb_Ctl)
Set Mctl(Nb_Ctl).Forme = uf
Select Case UCase(TypeName(Ctls))
Case "TEXTBOX"
Set Mctl(Nb_Ctl).CText = Ctls
Case "IMAGE"
Set Mctl(Nb_Ctl).CImg = Ctls
Case "COMBOBOX"
Set Mctl(Nb_Ctl).CCombo = Ctls
Case "CHECKBOX"
Set Mctl(Nb_Ctl).CCbx = Ctls
Case "COMMANDBUTTON"
Set Mctl(Nb_Ctl).CBtn = Ctls
Case "LABEL"
Set Mctl(Nb_Ctl).CLbl = Ctls
Case "FRAME"
Set Mctl(Nb_Ctl).CFr = Ctls
End Select
End Sub
Private Sub CText_Click()
Check_Txt_Parent(CText).Click_sur_TextBox CText.Caption, CText.Name
End Sub
Private Sub CText_Change()
Check_Txt_Parent(CText).Change_sur_TextBox CText.Caption, CText.Name
End Sub
Private Sub CText_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Check_Txt_Parent(CText).Keypress_sur_TextBox KeyAscii, CText.Name
End Sub
Private Sub CText_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Check_Txt_Parent(CText).KeyDown_sur_TextBox KeyCode, CText.Name
End Sub
Function Check_Txt_Parent(ct As MSForms.Control)
Set Check_Txt_Parent = Nothing
On Error Resume Next
Set Check_Txt_Parent = ct.Parent
Do Until Check_Txt_Parent.Name Like "UF* "
If Check_Txt_Parent.Name Like "UF*" Then Exit Do
Set Check_Txt_Parent = Check_Txt_Parent.Parent
Loop
End Function