Re-sizing for diff. Scr. Resolutions

nonney
09-10-2000, 11:20 PM
So far everything that I have coded in VB has been run on computers with a resolution of 800x600. Today I tried one of my projects out on a system using a resolution of 640x480, and was very shocked to see that only about 3/4 of the form appeared. So my question is...is there an easy way to accommodate different screen resolutions without having to basically re-size each and every control individually? The only solution that I could come up with would be to include a "Resolution" menu item with several different options for the user to choose from, with "If Then Else" statements used to resize each text box, label, etc. Ex.:

If ScrRes = "640x480" Then
txtTextBox1.Width = txtTextBox1.Width * .75
txtTextBox1.Height = txtTextBox1.Height * .75
etc., etc., etc.
End If

I know there has to be an easier way to do this, but with my limited programming experience I am unable to find an easier solution. Any help or hints will be greatly appreciated.

Thanks in Advance,
Rodney

ruti_gl
09-11-2000, 02:33 AM
I can propose you as minimum 3 solutions:

1. To create all of your projects and forms in minimal possible screen resolution
and to set all the Forms, PictureBoxes, etc. ScaleMode = 3 (Pixels) instead of 1 (Twips).

2. To add to your form SysInfo control and to add the manual resizement and/or movement
of all the necessary controls in SysInfo1_DisplayChanged() Event.

3. If you don't want to perform all this job manually, just e-mail me, and
I'll send you a free third-party resizer.ocx, which will automatically do it for you.

Good Luck!

Ruth Glushkin,
ruth@minicom.com

BillSoo
09-11-2000, 12:42 PM
You can detect the current screen resolution using the screen.width/height and screen.twipsperpixelx/y properties. For instance, width in pixels would be
screen.width / screen.twipsperpixelx

Also, individually resizing each control could be a mistake since your *fonts* may or may not resize properly, making your forms look even odder.

But if you were going to resize all the controls, I'd use the controls array.

dim ctr as Control

for each ctr in Controls
ctr.width = ctr.width * widthfactor
ctr.height = ctr.height * heightfactor
next ctr

"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

zoldy
09-11-2000, 03:05 PM
checkout this link I have used this and it works great !!
http://www.freevbcode.com/ShowCode.Asp?ID=618

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum