positioning a form in the center ?!?

  • Thread starter Thread starter BadButBit
  • Start date Start date
B

BadButBit

Guest
I've got a list of images of a square that I'm putting onto the form. The form fits itself to the size of the image and then is supposed to center itself on the screen. (the image size changes as the corners of the square stretch out then recede again while its being rotated) I want the square to be centered regardless of the angle and size of its bitmap.

basic.

here's my code to place it on the screen at center

void locate()
{
Size = new Size(lstBMP[intCounter].Width, lstBMP[intCounter].Height);
Point ptCenter = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2, Screen.PrimaryScreen.WorkingArea.Height / 2);

Location = new Point(ptCenter.X - Width / 2, ptCenter.Y - Height / 2);

}

some might call this easy (i did an hour ago and now I'm just banging my head on the wall)

instead of the image remaining centered it jumps by dozens of pixels as if it wasn't being positioned at all.

Why is this form not doing what I'm telling it to?

BadButBit


my code is perfect until i don't find a bug

Continue reading...
 
Back
Top