Option Explicit
Public a As Long
Public sngFrmTop As Single
Public sngFrmLeft As Single
Public sngFrmHeight As Single
Public sngFrmWidth As Single
Public Sub ControlResize(FormName As Form)
On Error GoTo ControlResize_Error
With FormName
If .WindowState = vbMinimized Then Exit Sub
sngFrmTop = .Top
sngFrmLeft = .Left
sngFrmHeight = .Height
sngFrmWidth = .Width
For a = 0 To .Controls.Count - 1
With .Controls(a)
.FontSize = Int(sngFrmHeight * ControlMetrix(a).sngCntFontSize)
.Top = sngFrmHeight * ControlMetrix(a).sngCntTop
.Left = sngFrmWidth * ControlMetrix(a).sngCntLeft
.Height = sngFrmHeight * ControlMetrix(a).sngCntHeight
.Width = sngFrmWidth * ControlMetrix(a).sngCntWidth
End With
Next a
End With
On Error GoTo 0
Exit Sub
ControlResize_Error:
If Err.Number = 383 Or Err.Number = 438 Or _
Err.Number = 380 Then
'Catch Error for controls with read only properties
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure ControlResize of Class Module Class1"
End If
End Sub
Public Sub GetFormMetrix(FormName As Form)
On Error GoTo GetFormMetrix_Error
With FormName
sngFrmTop = .Top
sngFrmLeft = .Left
sngFrmHeight = .Height
sngFrmWidth = .Width
ReDim ControlMetrix(.Controls.Count - 1)
For a = 0 To .Controls.Count - 1
With .Controls(a)
ControlMetrix(a).sngCntTop = (.Top / sngFrmHeight)
ControlMetrix(a).sngCntLeft = (.Left / sngFrmWidth)
ControlMetrix(a).sngCntHeight = (.Height / sngFrmHeight)
ControlMetrix(a).sngCntWidth = (.Width / sngFrmWidth)
ControlMetrix(a).sngCntFontSize = (.FontSize / sngFrmHeight)
End With
Next a
End With
On Error GoTo 0
Exit Sub
GetFormMetrix_Error:
If Err.Number = 13 Or Err.Number = 383 Or Err.Number = 438 Or _
Err.Number = 380 Then
'Catch Error for controls with read only properties
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure GetFormMetrix of Class Module Class1"
End If
End Sub