有点像windows里面的屏幕保护,设定一段时间,例如10min,如果这段时间之内用户没有移动鼠标或点击系统,则自动关闭系统。谢谢!
解决方案 »
- C#做二叉树查找出现问题,有大神帮一下小弟么?
- 请问winform状态栏跑马灯的效果怎么作?
- VS2008 我的Form怎么没有Dispose()?
- 怎样把帮助文档与c#.net连接在一起
- WPF 的System.Windows.Controls.Page如何得到这个Page上的所有控件
- 请问大家做Blog有没有什么好的软件介绍,主要做blog的前台!要好用的软件!
- 对象间如何通信最好
- app.config 加密后无法在另一台电脑上使用
- 要过年了,大家来讨论哈:各地的C#程序员的工资多少啊?
- 怎样终止线程才能不让那个ThreadAbortException出来?
- 100分问一个数据库更新中(未能启用约束.一行或多行中包含违反非空,唯一或外键约束的值.)的问题!顶者有分.
- 如何实现断词功能
{
this.close();//关闭窗体
}
使用Application.Idle Event
-----------------------------------
这才是高手阿
Application.Idle 事件
当应用程序完成处理并即将进入空闲状态时发生。
备注
如果您有必须在线程空闲以前执行的任务,请将它们附加到该事件。
TO:楼主:
在form中如何捕捉mouse move,mouse click 事件?我的是mdi form ,所以好像捕捉不到啊?好捕捉,只不过不是在属性窗口的Event中选择事件,而是自己写代码,当你输入+=时,VS IDE自动提示按TAB键键入后面的事件委托如,再提示按TAB键键入委托实例如ParentForm_Click,很方便,直接在ParentForm_Click、ParentForm_MouseMoveif (this.IsMdiChild)
{
this.ParentForm.Click+=new EventHandler(ParentForm_Click);
this.ParentForm.MouseMove+=new MouseEventHandler(ParentForm_MouseMove);
}private void ParentForm_Click(object sender, EventArgs e)
{
this.Close();
}private void ParentForm_MouseMove(object sender, MouseEventArgs e)
{
this.Close();
}
this.ParentForm.Click+=new EventHandler(ParentForm_Click);
this.ParentForm.MouseMove+=new MouseEventHandler(ParentForm_MouseMove);
哈哈,对不起搞返了,所索性都列出来在窗口拖一个timer控件,并设置Interval = 600000;//如果是MDI子窗口
if (this.IsMdiChild)
{
this.ParentForm.Click+=new EventHandler(Form_Click);
this.ParentForm.MouseMove+=new MouseEventHandler(Form_MouseMove);
}//本身,直接调用相同的过程
this.ParentForm.Click+=new EventHandler(Form_Click);
this.ParentForm.MouseMove+=new MouseEventHandler(Form_MouseMove);
private void Form_Click(object sender, EventArgs e)
{
this.timer1.Interval = 600000;
}private void Form_MouseMove(object sender, MouseEventArgs e)
{
this.timer1.Interval = 600000;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
this.Close();
}
//本身,直接调用相同的过程
this.ParentForm.Click+=new EventHandler(Form_Click);
this.ParentForm.MouseMove+=new MouseEventHandler(Form_MouseMove); 会出错
Application.Idle 事件
当应用程序完成处理并即将进入空闲状态时发生。
备注
如果您有必须在线程空闲以前执行的任务,请将它们附加到该事件。具体怎么用阿,有没有相关例子?
{
this.timer1.Interval = 600000;}private void timer1_Tick(object sender, System.EventArgs e)
{
this.Close();
}
{
this.timer1.Interval = 600000;}private void timer1_Tick(object sender, System.EventArgs e)
{
this.Close();
}
=========================
正解
支持
快刀X乱麻
private void timer1_Tick(object sender, System.EventArgs e)
{
this.close();
}