有点像windows里面的屏幕保护,设定一段时间,例如10min,如果这段时间之内用户没有移动鼠标或点击系统,则自动关闭系统。谢谢!

解决方案 »

  1.   

    在窗口中放一个timer控件,然后写窗口的mousemover、click等事件,当事件发生时就把time置为初始状态,当timer满了定时时就把窗口关闭
      

  2.   

    添加一个时间控件Timer1 TimerCloseWIndow=new Timer1();if(TimerCloseWIndow.Intervae>3000)
    {
       this.close();//关闭窗体
    }
      

  3.   

    在form中如何捕捉mouse move,mouse click 事件?我的是mdi form ,所以好像捕捉不到啊
      

  4.   

    fancyf(凡瑞) ( ) 信誉:133  2005-09-25 11:31:00  得分: 0   
     
       使用Application.Idle Event
      -----------------------------------
                   这才是高手阿 
      

  5.   

    MSDN:
    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();
    }
      

  6.   

    当然,不能把自己忘记了啊//直接调用相同的过程
    this.ParentForm.Click+=new EventHandler(ParentForm_Click);
    this.ParentForm.MouseMove+=new MouseEventHandler(ParentForm_MouseMove); 
      

  7.   


    哈哈,对不起搞返了,所索性都列出来在窗口拖一个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();
    }
      

  8.   

    那MDI窗口本身呢?好像用
    //本身,直接调用相同的过程
    this.ParentForm.Click+=new EventHandler(Form_Click);
    this.ParentForm.MouseMove+=new MouseEventHandler(Form_MouseMove); 会出错
      

  9.   

    to:flygoldfish(长江支流) 
    Application.Idle 事件
    当应用程序完成处理并即将进入空闲状态时发生。
    备注
    如果您有必须在线程空闲以前执行的任务,请将它们附加到该事件。具体怎么用阿,有没有相关例子?
      

  10.   

    this.ParentForm.Idle+=new EventHandler(Form_Idle);private void Form_Idle(object sender, System.EventArgs e)
    {
     this.timer1.Interval = 600000;}private void timer1_Tick(object sender, System.EventArgs e)
    {
     this.Close();
    }
      

  11.   

    this.ParentForm.Idle+=new EventHandler(Form_Idle);private void Form_Idle(object sender, System.EventArgs e)
    {
     this.timer1.Interval = 600000;}private void timer1_Tick(object sender, System.EventArgs e)
    {
     this.Close();
    }
    =========================
    正解
    支持
      

  12.   

    Application.Idle Event
    快刀X乱麻
      

  13.   

    用timer呀设置inertval=1000
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    this.close();
    }