Sunday, 29 September 2013

I did that the form1 will move slowly to the left. How can i make that it will start from the center of the screen?

I did that the form1 will move slowly to the left. How can i make that it
will start from the center of the screen?

At the top of Form1 i did:
private IntPtr ID;
private int counter = 0;
In the constructor i did:
ID = this.Handle;
timer2.Enabled = true;
Then in timer2 tick event i did:
private void timer2_Tick(object sender, EventArgs e)
{
if (counter <= Screen.PrimaryScreen.Bounds.Right)
MoveWindow(ID, counter++, 0, this.Width, this.Height, true);
else
counter = 0;
}
But the form start to move from the top left corner at 0,0 to the right. I
want the form will start to move from the center of the screen to the left
untill it hit the left border/bound and stop and stay there.
How can i do it ?
I found now how to make it to move to the left and stop on the left
border/bound:
private void timer2_Tick(object sender, EventArgs e)
{
if (counter >= Screen.PrimaryScreen.Bounds.Left)
MoveWindow(ID, counter--, 0, this.Width, this.Height, true);
else
counter = 0;
}
But how do i make that it will start to move from the middle/center of the
screen ? I did in the designer change the property: StartPosition to
CenterScreen But the form start to move from the top left corner 0,0

No comments:

Post a Comment