How to Make a Form Fit Any Size Screen of a Computer in VB6

Save

Visual Basic 6 is a programming language for Windows. The programmer draws controls like buttons and text boxes on a "form" (the VB6 term for a window). A form normally scales with the screen resolution, which means it will take up a larger portion of a low-resolution screen.


Sometimes you want a form to fit itself to the screen so that it fills the screen and looks the same at any resolution. This is particularly common with entertainment and presentation software.

  • Set the form's WindowState property to 2 (Maximized). This makes the form fill the screen when the program runs.

  • Set the form's BorderStyle property to 0 (None). This makes the form stretch to the edges of the screen instead of displaying a title bar and the Windows Taskbar.

  • Arrange the form's controls in its Resize event. This allows you to place the controls in the same relative position no matter what the form's actual size is. For example, this code moves a command button to the center of the form:

    Private Sub Form_Resize()

    Command1.Left = (Me.ScaleWidth - Command1.Width) / 2

    Command1.Top = (Me.ScaleHeight - Command1.Height) / 2

    End Sub

References

  • "Microsoft Visual Basic 6.0 Language Reference"; Maureen Williams Zimmerman; 1998
Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!