public Form1()
{
InitializeComponent();
// 默认情况下,窗体由操作系统分配位子
StartPosition = FormStartPosition.Manual;
Location = new Point(0, 0);
}

int seed = 5;
private void timer1_Tick(object sender, EventArgs e)
{
// 此时写在里面的东西20ms执行一次
int x = Location.X;
// if (x >= 1024 - Width || x < 0)
if (x >= Screen.GetWorkingArea(new Point(0, 0)).Width - Width || x < 0)
{
seed = seed * (-1);
}
Location = new Point(x + seed, Location.Y);

}

private void btnGetScreen_Click(object sender, EventArgs e)
{
Rectangle rect = Screen.GetWorkingArea(new Point(0, 0));

Text = rect.Width + " " + rect.Height;
}

相关文章:

  • 2021-07-30
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-11-08
相关资源
相似解决方案