How to code to open form as 85% of user's screen (width and height)?

aspfun

Active member
Joined
Feb 16, 2010
Messages
34
Programming Experience
5-10
Since screen resolutions in all pcs are different, set static form size is not good practice.
I knew how to set width and height of screen in fix number.
How to code to open form as 85% of user's screen (width and height)?
 
Last edited:
You can use the Screen class for this:

Const SCALEFACTOR = 0.85
Form1.Width = CInt(Screen.PrimaryScreen.Bounds.Width * SCALEFACTOR)
Form1.Height = CInt(Screen.PrimaryScreen.Bounds.Height * SCALEFACTOR)
 
Since screen resolutions in all pcs are different, set static form size is not good practice.
Um, no, it's perfectly good practice. Pretty much every application in the universe does so. If people want a different size then they can set a different size. What is good practice is for you to remember the size the window was when it was last used and use the same saize next time.
I knew how to set width and height of screen in fix number.
How to code to open form as 85% of user's screen (width and height)?
If you want to go that way then Screen.PrimaryScreen.WorkingArea will give you a Rectangle for the working area on the primary screen. You can then use a bit of simple maths to calculate the dimensions for your form and set its Size accordingly.
 
Back
Top