Resize a Form to the size of the screen
Submitted by: Song San
Email: songsan2000@yahoo.com
Date: 1/8/2002
Tested: Yes
How to Use it:
Copy the code and paste it to the "Form, Load" of your code. Make sure that frmForm1 is replace by the name of the form that you want to load in the center. So if your form name is Form1, then replace frmForm1 with Form1.
Code:
On Error Resume Next
If FrmName.WindowState <> 0 Then Exit Sub
' -- Calculate the X and Y resizing ratio
XRatio = Screen.Width / FrmName.Width
YRatio = Screen.Height / FrmName.Height
' -- Set the Form's Origin to 0,9
FrmName.Top = 0
FrmName.Left = 0
' -- Resize the Form's Height, Width, and Font Size
FrmName.Height = FrmName.Height * YRatio
FrmName.Width = FrmName.Width * XRatio
FrmName.Font.Size = FrmName.Font.Size * XRatio
For I = 0 To FrmName.Controls.Count - 1
FrmName.Controls(I).Left = FrmName.Controls(I).Left * XRatio
FrmName.Controls(I).Top = FrmName.Controls(I).Top * YRatio
FrmName.Controls(I).Height = FrmName.Controls(I).Height * YRatio
FrmName.Controls(I).Width = FrmName.Controls(I).Width * XRatio
FrmName.Controls(I).Font.Size = FrmName.Controls(I).Font.Size * XRatio
Next I