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
| Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function fwa Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'SUB DE DEMARAGE MEMORISATION DIMENTIONS
Sub depart(usf)
SetWindowLongA fwa(vbNullString, usf.Caption), -16, &H94CF0080 'Api window pour mettre les boutons minimiser et maximiser et l'élasticité
usf.Tag = usf.Width & ":" & usf.Height 'on memorise les dimention du userform dans son tag
nofont = "ScrollBar, SpinButton, Image" 'liste des controles qui n'ont pas de font
For Each Ctrl In usf.Controls
Ctrl.Tag = Ctrl.Left & ":" & Ctrl.Width & ":" & Ctrl.Top & ":" & Ctrl.Height 'on memorise les dimention des controles dans leur tag
If Not nofont Like "*" & Left(TypeName(Ctrl), 5) & "*" Then Ctrl.Tag = Ctrl.Tag & ":" & Ctrl.Font.Size 'si il y a la propriété font alors on memorise aussi le fontsize
If TypeName(Ctrl) = "ListBox" Then 'MEMORISATION DU COLUMNWIDTHS DE la listbox dans le tag sous la forme du string de l'array des dimentions
tablwidth = Split(Replace(Ctrl.ColumnWidths, " pt", ""), ";")
For i = 0 To UBound(tablwidth): tablwidth(i) = Val(tablwidth(i)): Next
Ctrl.Tag = Ctrl.Tag & ":" & Join(tablwidth, "|")
End If
Next
End Sub
'SUB RESIZER GLOBAL
Sub maform_resize(usf)
Dim WU, HU, D, Ctrl, tablwidth, i
WU = usf.Width / Val(Split(usf.Tag, ":")(0)): HU = usf.Height / Val(Split(usf.Tag, ":")(1)) 'calcul du proprata
For Each Ctrl In usf.Controls
D = Split(Ctrl.Tag, ":")
Ctrl.Move D(0) * WU, D(2) * HU, D(1) * WU, D(3) * HU 'redimentionnement par le prorata
If UBound(Split(Ctrl.Tag, ":")) > 3 Then Ctrl.Font.Size = Round(D(4) * HU) + 1 'il il y a la propriété font on redimentionne le font
If TypeName(Ctrl) = "ListBox" Then 'si c 'est une listbox on reconstruit le columnwidts avec l'array precédement memorisé dans le tag
tablwidth = Split(D(5), "|")
For i = 0 To UBound(tablwidth): tablwidth(i) = Val(tablwidth(i)) * WU: Next 'ON MET LES DIMENTIONS COLONNE A JOUR
Ctrl.ColumnWidths = Join(tablwidth, " pt;") 'reconstruction du string columnwidths
End If
Next
End Sub |
Partager