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

posted on 2012-07-13 00:11  Fan帥帥  阅读(167)  评论(0编辑  收藏  举报