Option Explicit
Function ptopx() 'fonction coeff point to pixel
Dim z#
With ActiveWindow.Panes(1): z = .Parent.Zoom / 100: ptopx = (.PointsToScreenPixelsX(72 * z) - .PointsToScreenPixelsX(0)) / 72: End With
End Function
Private Sub UserForm_Activate()
Dim W#, H#, capt#, border#, UFW#, UFH#, ratw#, rath#, ratfontSize&, ctrl
UFW = Me.Width: UFH = Me.Height
W = ExecuteExcel4Macro("CALL(""user32"",""GetSystemMetrics"",""jjj""," & 0 & ")") / ptopx
H = ExecuteExcel4Macro("CALL(""user32"",""GetSystemMetrics"",""jjj""," & 1 & ")") / ptopx
capt = ExecuteExcel4Macro("CALL(""user32"",""GetSystemMetrics"",""jjj""," & 14 & ")") / ptopx
border = ExecuteExcel4Macro("CALL(""user32"",""GetSystemMetrics"",""jjj""," & 32 & ")") / ptopx
Me.Move 0, 0, W, H - capt - border
ratw = Me.Width / UFW: rath = Me.Height / UFH
ratfontSize& = Application.Min(ratw, rath)
For Each ctrl In Me.Controls
With ctrl: .Move .Left * ratw, .Top * rath, .Width * ratw, .Height * rath:
On Error Resume Next
.Font.Size = .Font.Size * ratfontSize
Err.Clear
End With
Next
End Sub