Todd Myhre
Todd Myhre

Reputation: 1310

Image Misalignment in Visual Studio application

I have a Visual Studio application with a splash screen image cut into "slices". The positions are specified in the Form Designer so they line up properly on the screen. However, the images are out of place when the application is run on the Chinese version of Windows XP. It looks as if the image slices were "exploded" apart.

What's going on here? Do international versions of Windows have a different meaning of the "top left" coordinate of the picture? How can I force the images to be precisely displayed where I want them?

Upvotes: 0

Views: 245

Answers (2)

Todd Myhre
Todd Myhre

Reputation: 1310

We found a solution! Apparently the picture boxes stretched out on the Chinese XP PC, but the images they contained did not. The fix was to add code like the following:

Me.PictureBoxIcon.Width = Me.PictureBoxIcon.Image.Width
Me.PictureBoxIcon.Height = Me.PictureBoxIcon.Image.Height

Dim loc As New Point
loc.X = Me.PictureBoxIcon.Location.X
loc.Y = Me.PictureBoxIcon.Location.Y + Me.PictureBoxIcon.Height
Me.PictureBoxAbout.Location = loc
Me.PictureBoxAbout.Width = Me.PictureBoxAbout.Image.Width
Me.PictureBoxAbout.Height = Me.PictureBoxAbout.Image.Height

Hope this helps someone else!

Upvotes: 2

Benjamin Autin
Benjamin Autin

Reputation: 4171

In the OnLoad event of the form, you could always explicitly set the location of each section. If starting at the top left with the first and assuming an array with the images in order:

images[0].Location = new Point(0,0);
for (int i = 1; i < images.Length; i++)
{
  images[i].Location = new Point(images[i - 1].Location.X + images[i - 1].Width, 0);
}

That will set the first image to the top left corner and all subsequent images to just after the last image.

Upvotes: 0

Related Questions