Sub ResizeForm(frm As Form)

'Esta rotina  utilizada para redimencionar todos os controles do form de acordo
'com a resoluo definida no Windows.
'Deve ser incluida no mdulo do projeto e no Form_Load incluir: ResizeForm Me

Dim wStart As Integer
Dim hStart As Integer
Dim wFactor As Single
Dim hFactor As Single
Dim LoopIndex As Integer
Dim ThisControl As Control
Dim Ind As Byte
Const DesignX = 640
Const designY = 480
wStart = Screen.Width / Screen.TwipsPerPixelX
hStart = Screen.Height / Screen.TwipsPerPixelY
wFactor = wStart / DesignX
hFactor = hStart / designY
On Error Resume Next
For LoopIndex = 0 To frm.Controls.Count - 1
Set ThisControl = frm.Controls(LoopIndex)
ThisControl.Left = ThisControl.Left * wFactor
ThisControl.Width = ThisControl.Width * wFactor
ThisControl.FontSize = ThisControl.FontSize * wFactor
ThisControl.Height = ThisControl.Height * hFactor
If TypeOf ThisControl Is Screen Then
ThisControl.Row = 1
For Ind = 1 To ThisControl.MaxCols
ThisControl.Col = Ind
ThisControl.ColWidth(Ind) = ThisControl.ColWidth(Ind) _
* (wFactor + 0.02)
Next
ThisControl.Col = 1
For Ind = 1 To ThisControl.MaxRows
ThisControl.Row = Ind
ThisControl.RowHeight(Ind) = ThisControl.RowHeight(Ind) _
* (hFactor - 0.1)
Next
End If
ThisControl.Top = ThisControl.Top * hFactor
Set ThisControl = Nothing
Next
frm.Width = frm.Width * wFactor
frm.Height = frm.Height * hFactor

End Sub

