Solved

Persistent fractional Width and Height, unequal to Scale

Posted on 2002-05-04
7
198 Views
Last Modified: 2010-05-02
I have an ordinary form (BorderStyle None) with labels and so forth on it.

I want to make the Width and ScaleWidth the same, and
an integral value.  Ditto for Height.

The problem is:

1.  Changing one makes the other change to something else.
2.  Changing either to a whole number makes it change only
    to a near by fractional number, listed to three decimal
    places.
This applies to both the form and some of the controls on it.

How can I regain control of Width and Height?

I have this problem in both VB 4.0 and VB 6.0 SP3.
0
Comment
Question by:markogonzo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6990023
Width and scalewidth are not the same thing.
0
 

Author Comment

by:markogonzo
ID: 6990064
I'm aware of that.  In any case
1.  I don't want Width to be fractional.
2.  It would be useful to set the ScaleWidth
    equal to the Width.
Ditto for Height.
0
 

Author Comment

by:markogonzo
ID: 6990089
I'm aware of that.  In any case
1.  I don't want Width to be fractional.
2.  It would be useful to set the ScaleWidth
    equal to the Width.
Ditto for Height.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 6

Accepted Solution

by:
pierrecampe earned 250 total points
ID: 6990676
i'll try to explain what happens:
i'll suppose the forms scalemode is twip
you'l see that in the design environment you cannot set a forms width/height to anything but a multiple of screen.twipsperpixelX/Y
that is because it is inpossible to draw between the screens pixels
now if you change a forms width/height to a number that is not a multiple of screen.twipsperpixelX/Y your forms width/height WILL be the nearest possible width that IS a multiple of screen.twipsperpixelX/Y
my screens screen.twipsperpixelX/Y is 15
say at run time i make my forms width 4000 twips than it WILL be 4005 twips
but vb will tell you it is 4000 twips (i suppose you could call that a bug ?)
now if you have a form with no borders then the width will be the same as the scalewidth (supposing you have not yet changed the scalewidth)
and if you ask the forms width vb will say 4000 and if you ask the scalewidth it will say 4005
but in reality your forms width WILL be 4005
now the scalewidth:
if you change the scalewidth then you are actually saying that the inside of your form is no longer to be measured in twips but in the units you gave
say if you change the scalewidth to 100 and scaleheight to 100 then the top left coordinate will be 0,0 and the bottom right will be 100,100
so if you change the scalewidth and AFTER that the width and the ratio of the change is not a divisor of the scalewidth then the scalewidth will be a non integer
suppose you have a width of 5880 (form without borders)
then you'l have a scalewidth of 5880 to
suppose you change the scalewidth to 200
then you'l have a width of 5880 and a scalewidth of 200
now if you make your forms width 4005 its scalewidth will be 136,2245
because 5880/4005 is 1.468164794 and 200/1.468164794 = 136,244897
also keep in mind that if you have a form without borders its runtime width will be smaller then its designtime width
 

0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 6990684
>>1.  I don't want Width to be fractional.
use twips or pixels and your width will never be fractional
>>2.  It would be useful to set the ScaleWidth equal to the Width.
if your form has no borders and you dont set scalewidth then scalewidth will always be the same as the width

 
0
 

Author Comment

by:markogonzo
ID: 6994232
pierrecampe  --

Thank you for your comment, which I've accepted
as an answer.
0
 

Author Comment

by:markogonzo
ID: 6995133
For future reference, here's pierrecampe's
comment with some minor copy-editing to make
is easier to read.
=================================================

Suppose your form's scalemode is twip.  You see that
setting in the design environment.

You cannot set a form's width/height to anything
but a multiple of screen.twipsperpixelX/Y.   That's
because it's inpossible to draw between the screen's
pixels.

Now if you change a forms width/height to a number
that's not a multiple of screen.twipsperpixelX/Y
your forms width/height will be the nearest possible
width that IS a multiple of screen.twipsperpixelX/Y.

For example, my screen's screen.twipsperpixelX/Y is 15.
Say at run time I make my forms width 4000 twips, then
it will actually be 4005 twips, but VB will tell you it
is 4000 twips (I suppose you could call that a bug).

Now if you have a form with no borders, the width will
be the same as the scalewidth (supposing you have not
yet changed the scalewidth) and if you ask VB, it will
say the forms width is 4000 and if you ask the scalewidth
it will say 4005, but in reality your forms width will
be 4005.  

As for the scalewidth, if you change the scalewidth you
are actually saying that the inside of your form is no
longer to be measured in twips but in the units you gave.  

Say if you change the scalewidth to 100 and scaleheight
to 100.  Then the top left coordinate will be 0,0 and the
bottom right will be 100,100.  So if you change the
scalewidth and AFTER that the width, and the ratio of
the change is not a divisor of the scalewidth, then the
scalewidth will be a non integer.

Suppose you have a width of 5880 (form without borders),
then you'll have a scalewidth of 5880.  Suppose you change
the scalewidth to 200,  then you'll have a width of 5880
and a scalewidth of 200.  Now if you make your form's
width 4005 its scalewidth will be 136.2245 because
5880/4005 = 1.468164794 and 200/1.468164794 = 136.244897.

Also keep in mind that if you have a form without borders
its runtime width will be smaller then its designtime width.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Microsoft Access combo box help 2 57
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 63
Export Data to Different .csv Files 27 131
checkbox to hide entire section 10 74
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question