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;
}