Hi everyone,
I am having problem with the screen resolution in VB. how can i make my project( the screen designing) to look good on every system ?
Printable View
Hi everyone,
I am having problem with the screen resolution in VB. how can i make my project( the screen designing) to look good on every system ?
The following is a simple code that you can use to make a form designed in 800x600 mode uniform over all resolutions.
private Sub Form_Load()
on error resume next
Dim CtrlVar as Control
Xratio = Screen.Width / (Screen.TwipsPerPixelX * 800)
Yratio = Screen.Height / (Screen.TwipsPerPixelY * 600)
for Each CtrlVar In FrmVar.Controls
CtrlVar.Left = CtrlVar.Left * Xratio
CtrlVar.Top = CtrlVar.Top * Yratio
CtrlVar.Width = CtrlVar.Width * Xratio
CtrlVar.Height = CtrlVar.Height * Yratio
CtrlVar.Font.Size = CtrlVar.Font.Size * XRatio
next CtrlVar
End Sub
Actuallu i find it's not working well. The calculation for XRatio and YRatio is incorrect. Maybe we need to use other property something? like scalex?
Thanks!
Best Regards,
Kevin Shen