Public Sub SameSizeApplication(Usf As Object) 'utilisé
Dim ctl As Control, ratioW#, ratioH#, tbCw, i&
With Application: ratioW = .UsableWidth / Usf.Width: ratioH = .Height / Usf.Height: End With
Usf.Move 0, 0, Usf.Width * ratioW, Usf.Height * ratioH
For Each ctl In Usf.Controls
ctl.Move ctl.Left * ratioW, ctl.top * ratioH, ctl.Width * ratioW, ctl.Height * ratioH
On Error Resume Next
ctl.Font.Size = Round(ctl.Font.Size * Application.Min(ratioH, ratioW))
On Error GoTo 0
If TypeName(ctl) = "ListBox" Or TypeOf ctl Is ListBox Then
If ctl.ColumnWidths <> "" Then
tbCw = Split(Replace(ctl.ColumnWidths, " pt", ""), ";")
For i = LBound(tbCw) To UBound(tbCw): tbCw(i) = val(tbCw(i)) * ratioW: Next
ctl.ColumnWidths = Join(tbCw, ";")
End If
End If
Next
End Sub
'''-------------------------------------
Public Sub ShowFullScreenUserForm(Usf As Object)
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Usf.Caption)
' Mettre le UserForm en plein écran sans barre de titre
SetWindowLongA hwnd, -16, &H94080080
ShowWindow hwnd, 3
' Ajuster les contrôles en fonction du nouveau format
SameSizeApplication Usf
End Sub