|
-
Sep 18th, 2001, 11:37 PM
#1
Thread Starter
Junior Member
Roundoff error in moving picture boxes
When moving picture boxes in run time using either equations or discrete X,Y coordinates, my picture boxes are not going exactly where they should go, but are rather quite visually off (they look sloppy). And not just a little bit, but off by 20 to 30 in screen units.
All variables are set to the "single" type. There couldn't be THAT much roundoff error! Does anyone know what gives here?
-
Sep 19th, 2001, 03:57 AM
#2
PowerPoster
hi
Ur picture boxes will be positioned at the nearest pixel calculated from the twipsperpixel[x or y] property. So, the easiest way to ensure that ur boxes line up is to calculate each value divided by the t-per-p property and round appropriately.
The Single data type wont cos a prob with the X & Y positions but it can be inaccurate if u are using singles for dividing / multiplying in formulae before u position the controls - u can use doubles instead.
Regards
Stuart
-
Sep 19th, 2001, 12:50 PM
#3
Frenzied Member
You could also be having some problem with the ScaleMode... remember to always set it to 3 - Pixels
-
Sep 19th, 2001, 01:26 PM
#4
Thread Starter
Junior Member
Beachbum....thank you for your reply. How do you use TwipsPerPixelY and TwipsPerPixelX? None of any of the objects (the form, picture boxes, etc.) have such a property. MSDN help says to use the command "object.TwipsPerPixelX" (or Y) to determine "the number of twips per pixel" for any given object. However, use of such a command returns the runtime error, "Compile Error: Method or data member not found."
-
Sep 19th, 2001, 07:36 PM
#5
PowerPoster
Hi again
use the screen object ie screen.twipsperpixelX (Y)
Regards
Stuart
-
Sep 20th, 2001, 10:51 AM
#6
Thread Starter
Junior Member
beachbum and Jotaf98,
Thank you for your help so far. O.k., the commands
screen.TwipsPerPixelY
screen.TwipsPerPixelX
return 15 each.
So now I'm quite confused. Here's some math:
My screen width is about 18 inches, at a screen resolution of 1280 x 1024. That's 1280/18 = 71 pixels per inch.
And twips are about 1440 per 'logical' inch.
1440/71 = 20 ...which is 'about' 15 (close enough)
So.............if Twips are FINER than pixels, then what good does it do to change the scalemode to Pixels? And if there's a +/- one or two Twips round-off error, how could that cause picture boxes to be placed so poorly (they don't line up, look sloppy)? Am I just totally confused here?
Thanks tons
-
Sep 20th, 2001, 04:14 PM
#7
-
Sep 24th, 2001, 05:45 PM
#8
Thread Starter
Junior Member
It worked great!
Thank you Jotaf98 and beachbum...your super advice and informed suggestestions worked perfectly! For whatever, bizarre reason, changing scalemode to 3 (pixel) instead of the much-finer unit of Twips fixed the problem!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|