C#编写一屏幕保护程序

来源:百度知道 编辑:UC知道 时间:2024/06/02 04:03:53
功能描述:
 鼠标移动、鼠标按下、键盘按下停止屏幕保护程序运行
 编写一带有文字和图片的屏幕保护程序
 解决方案
1.在Visual Studio.Net下新建一个C#的Windows应用程序工程,不妨命名为screen_saver。
2.设计程序的主界面:
先将窗体的Name属性设置为screen、Text属性设置为空,BackColor属性设置为Black、Size属性设置为(800, 600)、 ControlBox、MaximizeBox、MinimizeBox、ShowInTaskbar属性设置均为false、 FormBorderStyle属性设置为None。再往窗体上添加Label控件、PictureBox控件、Timer控件各一个。将Label控件的Name设置为word、Text属性设置为空;将PictureBox控件的Name设置为picture1、Image设置为一个预知图片;将 Timer控件的Name设置为timerSaver、Enabled 属性设为true、Interval属性设为5。
3. 设置文本显示控件(word)、 计时器控件、图片控件、窗体(screen)属性

做的好有追加 作业..没办法
633805 我QQ 方便的话发给我

//判断鼠标的坐标值
if ((po.X == MousePosition.X) && (po.Y == MousePosition.Y))
{
//增加1秒时间
count += 1;

//如果静止时间达到5秒钟
if (count == 5)
{
this.Show();
//this.TopMost = true;
timer1.Start();
timer2.Stop();
}
}
else
{
//鼠标坐标不一样,则每次都更换旧的值
po = MousePosition;
this.count = 0;
}
private void timer1_Tick(object sender, EventArgs e)
{

Random ran = new Random(DateTime.Now.Second+DateTime.Now.Millisecond);
this.panel1.Location=new Point(ran.Next(0, this.Width),ran.Next(0, this.Height));

}