Option Explicit
Private EchX As Double, EchY As Double
Private Sub UserForm_Initialize()
Dim Ctl As MSForms.Control
EchX = Me.InsideWidth: EchY = Me.InsideHeight
Me.Width = Application.Width - 12: Me.Height = Application.Height - 12
EchX = Me.InsideWidth / EchX: EchY = Me.InsideHeight / EchY
For Each Ctl In Me.Controls
Ctl.Left = Ctl.Left * EchX: Ctl.Width = Ctl.Width * EchX
Ctl.Top = Ctl.Top * EchY: Ctl.Height = Ctl.Height * EchY
Ctl.Font.Size = Ctl.Font.Size * EchY
Next Ctl
ComboBox1.List = Array("", "M.", "Mme", "Mlle")
End Sub
Private Sub ListBoxDyn_Click()
'création dynamique d'un ListBox
Dim MylistBox As MSForms.ListBox
Set MylistBox = Controls.Add("Forms.ListBox.1")
With MylistBox
.Left = 102 * EchX
.Top = 36 * EchX
.Height = 120 * EchY
.Width = 246 * EchX
.Name = "maboite"
.BackColor = &H8080FF
.AddItem ("eee")
'mis on omet ce MsgBox, le ListBox dynamique n'est pas rdimensionné
' MsgBox "Si on met ce Msgbox en commentaire, le redimensionnement du listbox ne se fait pas"
Label1.Caption = "Le redimensionnement du Listbox a lieu mais pas au bon endroit"
End With
End Sub
'Private Sub Quitter_Click()
' Me.Hide
' Label1.Caption = "Il faut cliquer deux fois le bouton 'Quitter' pour sortir"
' End Sub
'Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
' If CloseMode = vbFormControlMenu Then Cancel = True
' End Sub