c#简单屏幕保护程序,共4个线程
2015-03-31 15:43
441 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
namespace WindPingBao02
{
public partial class Form1 : Form //共4个线程
{
int temp,dx,dy;
[DllImport("user32.dll", EntryPoint = "ShowCursor", CharSet = CharSet.Auto)]
public extern static void ShowCursor(int status); //声明函数(显示鼠标)
public Form1()
{
InitializeComponent();
temp = 0;
dx = Control.MousePosition.X;
dy = Control.MousePosition.Y;
ShowCursor(0);//隐藏鼠标
this.timer1.Enabled = true;//开始计时
//Thread.Sleep(1000);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);//添加鼠标移动事件
}
private void timer1_Tick(object sender, EventArgs e)
{
if (temp == 0)
this.label1.Location = new Point(label1.Location.X -400,label1.Location.Y+300);
else if(temp == 1)
this.label1.Location = new Point(label1.Location.X + 400, label1.Location.Y + 300);
else if (temp == 2)
this.label1.Location = new Point(label1.Location.X + 400, label1.Location.Y - 300);
else if (temp == 3)
this.label1.Location = new Point(label1.Location.X - 400, label1.Location.Y - 300);
if ((temp == 3)) temp = 0;
else temp++;
}
//加以判断,减少灵敏度。XY移动均大于20才执行
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if ((Control.MousePosition.X - dx > 20 || dx - Control.MousePosition.X > 20) &&
(Control.MousePosition.Y - dy > 20 || dy - Control.MousePosition.Y > 20))
{
ShowCursor(1);
this.Close();
}
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
ShowCursor(1);
this.Close();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
namespace WindPingBao02
{
public partial class Form1 : Form //共4个线程
{
int temp,dx,dy;
[DllImport("user32.dll", EntryPoint = "ShowCursor", CharSet = CharSet.Auto)]
public extern static void ShowCursor(int status); //声明函数(显示鼠标)
public Form1()
{
InitializeComponent();
temp = 0;
dx = Control.MousePosition.X;
dy = Control.MousePosition.Y;
ShowCursor(0);//隐藏鼠标
this.timer1.Enabled = true;//开始计时
//Thread.Sleep(1000);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);//添加鼠标移动事件
}
private void timer1_Tick(object sender, EventArgs e)
{
if (temp == 0)
this.label1.Location = new Point(label1.Location.X -400,label1.Location.Y+300);
else if(temp == 1)
this.label1.Location = new Point(label1.Location.X + 400, label1.Location.Y + 300);
else if (temp == 2)
this.label1.Location = new Point(label1.Location.X + 400, label1.Location.Y - 300);
else if (temp == 3)
this.label1.Location = new Point(label1.Location.X - 400, label1.Location.Y - 300);
if ((temp == 3)) temp = 0;
else temp++;
}
//加以判断,减少灵敏度。XY移动均大于20才执行
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if ((Control.MousePosition.X - dx > 20 || dx - Control.MousePosition.X > 20) &&
(Control.MousePosition.Y - dy > 20 || dy - Control.MousePosition.Y > 20))
{
ShowCursor(1);
this.Close();
}
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
ShowCursor(1);
this.Close();
}
}
}
相关文章推荐
- 用C#写的一个简单屏幕保护程序
- C# 窗口实现Win7简单屏幕泡泡保护程序 和实现聊天窗口震动
- android 屏幕保护程序--------Fade In 与 Fade Out 特效与运行线程
- 打造自己的c#屏幕保护程序(,源码)
- 简单对比C#程序中的单线程与多线程设计
- 使用Python 启动windows 屏幕保护程序 及在线程中启动
- Unity在协成程序,C#的线程,Invoke的简单解释
- [C#] 屏幕保护程序 - 随机变换图像、音乐
- 使用C#开发屏幕保护程序步骤
- c#制作屏幕保护程序步骤(字幕屏保)
- c#屏幕保护程序
- 屏幕保护程序制作基础
- 用汇编编写屏幕保护程序
- 深入浅出屏幕保护程序编程 (http://www.zahui.com/html/1/559.htm)
- 用c#实现类似QQ的简单通讯程序
- 屏幕保护程序的编写
- 改编的一个屏幕保护程序
- 在root下运行gdesklets和屏幕保护程序
- C#事件演示程序1)——一个最简单的C#事件处理程序
- [C#] 简单的木马程序