Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Forms sample source codes
Resizing A Form To Fit The Screen
Resizing A Form To Fit The Screen Private Sub ResizeFormToScreen(FrmName) 'The 'On Error Resume Next' is needed because there might be 'some controls on the form that may not support some of the 'properties that will be set On Error Resume Next 'If the form's windows state is minimized or maximized then exit 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,0 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 'Loop through all the controls on the from and repostion every 'control relative to the form origin, then resize thier width, 'height, and Font.Size properties 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 'Note: The control's font will resize only if it is a truetype font FrmName.Controls(I).Font.Size = FrmName.Controls(I).Font.Size * XRatio Next I End Sub
Privacy Policy
|
Link to Us
|
Links