注册 登录
编程论坛 C# 论坛

求 c# 写 屏保 小程序

风中追疯 发布于 2014-07-24 12:45, 550 次点击
求c#写 屏保 小程序 要源码的
3 回复
#2
邓士林2014-07-24 22:16
#3
yanglin_gdqy2014-07-26 03:25
程序代码:

using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        /// <summary>
        
/// 屏保From1, 在该窗体属性上 设为无边窗体,状态设为最大化
        
/// </summary>
        public Form1()
        {
            InitializeComponent();
        }

        Point MousePosition;//p1用于获取屏保启动时鼠标位置
        private void Form1_Load(object sender, EventArgs e)
        {
            Cursor.Hide();//隐藏鼠标
            MousePosition = new Point(Cursor.Position.X,Cursor.Position.Y);//记下鼠标初始位置
            timer1.Start();
        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)//按下键盘时,屏保关闭
        {
            this.Close();
        }
      
        //通过计时器判断鼠标位置是否改变
        private void timer1_Tick(object sender, EventArgs e)
        {
            if(MousePosition != Cursor.Position)//鼠标位置改变时,屏保关闭
            {
                this.Close();
            }
        }
        private void Form1_Deactivate(object sender, EventArgs e)//当前窗体被挂起时,屏保关闭
        {
            this.Close();
        }
        private void Form1_MouseClick(object sender, MouseEventArgs e)//鼠标点击时,屏保关闭
        {
            this.Close();
        }
    }
}
#4
漫檬2014-08-05 13:25
牛人,代码收下了
多谢,多谢
1