Form1 の上部で、次のことを行いました。
private IntPtr ID;
private int counter = 0;
コンストラクターで私がした:
ID = this.Handle;
timer2.Enabled = true;
次に、timer2 ティック イベントで次のことを行いました。
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;
}
しかし、フォームは 0,0 の左上隅から右に移動し始めます。フォームが画面の中央から左に移動し始め、左の境界/境界に達して停止し、そこにとどまるまでフォームを動かしたい.
どうすればできますか?
左に移動して左の境界/境界で停止する方法を見つけました。
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;
}
しかし、画面の中央/中央から動き始めるようにするにはどうすればよいですか? デザイナーでプロパティを変更しました: StartPosition to CenterScreen しかし、フォームは左上隅から移動し始めます 0,0