Images changing size between Win98 and XP

Rockyh
01-06-2005, 02:57 PM
I can't seem to find an answer to this, hopefully someone here can help. I have developed several applications for VB 6 on Windows 98. Frequently, I put my company's logo in an Image control. It looks great on 98, but I was shocked that when these applications were run on XP the graphic is too large for the image box. This doesn't seems to be a screen resolution issue, as I have tried all different resolutions, and I get the same results. I have started developing on XP, but when my application is run on 98, I have the opposite problem (graphic too small).

What is causing this, and more importantly, how can I fix this problem?

Rocky

OnErr0r
01-06-2005, 06:46 PM
The Windows Font Size (normal/large/extra large, etc) now called DPI on XP is the problem. You'll notice the ratio of twips to pixels is different. Size the image using Screen.TwipsPerPixelX/Y and the number of pixels, or use a picturebox with autosize = true.

Busted Bumper
01-07-2005, 02:27 PM
There is a tool available that you can add to vb. It is called Active resize. Take a look at this site. http://www.vbgold.com/

Rockyh
01-21-2005, 12:26 PM
OnErr,
Thank you, I know what you are saying is correct. But I'm not really sure I understand your solution. Are you saying that TwipsPerPixel changes when the font DPI in XP changes? How do I find out what it is set to? Am I understanding that if I know what the Twips to pixel ratio is when I design my form, that I can use "Screen.TwipsPerPixelX/Y" to hard set it so those values are always used regardless of the machine my program is run on?
Thank you for your reply!

noi_max
01-21-2005, 12:53 PM
I thought that Screen.TwipsPerPixel actually returned the current value.

Dim tppX As Long

'On my current machine, this returns a value of 15
tppX = Screen.TwipsPerPixelX

myPic.Width = 50 * tppX '50 pixels wide


One other thing is that the Image control has a .Stretch property that if set to True, will stretch or shrink the image to fit in the Image control.
The downside to that is you run the potential of losing your aspect ratio.

OnErr0r
01-21-2005, 12:57 PM
OnErr,
Thank you, I know what you are saying is correct. But I'm not really sure I understand your solution. Are you saying that TwipsPerPixel changes when the font DPI in XP changes? How do I find out what it is set to? Am I understanding that if I know what the Twips to pixel ratio is when I design my form, that I can use "Screen.TwipsPerPixelX/Y" to hard set it so those values are always used regardless of the machine my program is run on?
Thank you for your reply!

Rather than hardcode the imagebox dimensions (as you are doing currently) you would get the value of Screen.TwipsPerPixelX/Y and use it in calculations for the width and height at runtime.

WidthInTwips = WidthInPixels * Screen.TwipsPerPixelX
etc.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum