VB6 - setting form size in pixels

Hi,

I'm trying to set the form design property so it has a size of 1280 x 768 pixels - thing is, I can't figure out how to do this. I've set the ScaleWidth and ScaleHeight to 1280 and 768 respectively, but I can't be sure that this has worked as intended. Help?

Thanks,
Uni
LVL 3
Unimatrix_001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frosty555Commented:
The form's width/height itself, though, is always measured in twips. Regardless of the scalemode property.

If you change form's scalemode property to "pixels". All sub-objects inside the form will now use "pixel" width and heights. So a label or button or textbox will use regular pixel sizing like you would expect.

The form, however is always in twips. You can get the ratio between twips and pixels using Screen.twipsperpixelx and Screen.twipsperpixely. So if you want your form to always be 1280x768 put in your form's LOAD event:

      Form1.Width = 1280 * Screen.TwipsPerPixelX
      Form1.Height = 768 * Screen.TwipsPerPixelY


1
Unimatrix_001Author Commented:
Hi Frosty, ok thanks - although how can I do this at design time when I'm laying out the components for a single resolution?
0
Frosty555Commented:
Forgot to mention:

Consider the Form.ScaleWidth and Form.ScaleHeight properties to be *read only*. If you change them, you do not change the size of the form. Instead, you change the ratio of twips to "form units", and thus the Form's scalemode property will automatically get set to "user".

Use the scalewidth and scaleheight when you need to figure out what the size of the form is. Use the width/height multiplied by twipsperpixel when you want to set the size.

You might notice picturebox's have their own scalemode/scalewidth/scaleheight properties. They act just like forms: The picturebox's width will always be whatever the form was set to. Objects INSIDE of the picturebox will have width/height based on the scalemode of the picturebox.

So if you are putting picturebox's on your form and using it like a container (putting other objects inside your picturebox), make sure you set your picturebox's scalemode too.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Frosty555Commented:
Form width and height is always measured in twips.

Twips are a measure of size that is dependant on the DPI of the user's computer. With normal size fonts (72 dpi), 1 twip = 15 pixel, but on many new laptops, a "large" font of 120dpi is used, and in this case one twip is more than 15 pixels.

Since form width and height is always measured in twips, you cannot set this at design time. You must set it in code. For visual sake, you may set the form's width and height to be equal to 19200 x  11520, but be aware that this is a measurement in twips, and changing your DPI size, or moving to another computer with a different DPI size, will cause the form to no longer be 1280x768 pixels, unless you explicitely resize the form in it's Form_Load() event.

You should probably get in the habit of using twips though, it makes your program easily scale for users who do not use standard DPI settings. Only use pixels if you have a real reason to.
0
Unimatrix_001Author Commented:
I'm slowly getting my head around the idea of using twips, although:

You should probably get in the habit of using twips though, it makesyour program easily scale for users who do not use standard DPIsettings. Only use pixels if you have a real reason to.You should probably get in the habit of using twips though, it makes your program easily scale for users who do not use standard DPI settings. Only use pixels if you have a real reason to.

This confuses me a bit - how can I design my program for X, Y twips and expect it to look the same if it is ran on a computer with W, Z twips?
0
Frosty555Commented:
VB internally converts all twip units into pixels just before drawing it on the screen. The ratio of twips to pixels changes with the DPI.

If you use twips as your unit, if the program is run on a computer with a higher DPI setting the fonts will scale up, but so will the form size, the size of the buttons and labels, and everything else on the form, because twips vary with DPI too. Everything will appear "bigger" as you would expect it to.

If you use pixels, and you run your program on a computer where somebody has cranked up the DPI, all the fonts will be bigger but the form and object positions / sizes will stay the same, resulting in a crowded form where everything is clipping and overlapping. Potentially some things may be unreadable or unusable as a result.

In the old days, this wasn't a problem, since so few people actually changed the DPI settings, but a lot of modern laptops come with 120dpi set as a standard... so you need to accomodate that.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Unimatrix_001Author Commented:
Thank you - you've cleared a lot up for me. :-)
0
Unimatrix_001Author Commented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.