返回主屏幕(如果未使用) [英] Return to main screen if unused

查看:59
本文介绍了返回主屏幕(如果未使用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行Windows项目.在其中,如果一分钟内未使用任何屏幕,则应返回到主屏幕.我是这样的.

I am doing a windows project.In it, If any screen is unused for a minute, then it should return back to home screen. I have done like this.

timer1.Tick+=new EventHandler(OnTimedEvent);
          timer1.Interval = 10000;
          timer1.Enabled = true;





private void OnTimedEvent(object source, EventArgs e)
      {
          TouchedFn();
if(touched == false)
//go to home page

}





private void TouchedFn()
    {
      this.MouseClick+=new MouseEventHandler(frmrecepArab_MouseClick);
        this.MouseMove+=new MouseEventHandler(frmrecepArab_MouseMove);
        timer1.Enabled = false;
        touched = true;
    }



我不知道这是对还是错..但是问题是,没有触发mouseclick和mousemove事件.谁能帮我这个忙.真的很紧急..
谢谢



I dont know this is right or wrong.. but the problem is that,mouseclick and mousemove event is not fired. Can anyone help me in this. Its really very urgent..
Thanks

推荐答案

有点...嗯...很奇怪.

我会做一些不同的事情.
在Load事件中设置一个间隔为一秒的计时器.
给它一个事件处理程序.
设置一个类级别的整数变量并将其设置为60.
启动计时器.

That is a bit...um...weird.

I would do it a bit differently.
Set up a timer in your Load event that has an interval of one second.
Give it an event handler.
Set up a class level integer variable and set it to 60.
Start the timer.

Timer pageTimer = new Timer();
pageTimer.Interval = 1000;
pageTouchCounter = 60;
pageTimer.Tick += new EventHandler(pageTimer_Tick);



在滴答"事件中,检查并减少计数:



In the Tick event, check and reduce the count:

void pageTimer_Tick(object sender, EventArgs e)
    {
    if (pageTouchCounter-- <= 0)
       {
       pageTimer.Stop();
       Close();
       }
    }

Close方法调用将关闭此表单-因此您可以隐藏主表单,给定时表单显示ShowDialog,然后再次显示主表单.

然后在构成活动的事件中,只需将pageTouchCounter重置为60.

The Close method call will close this form - so you can Hide the main form, ShowDialog you timed form, then Show the main form again.

Then in the events that constitute activity, just reset pageTouchCounter to 60.


这篇关于返回主屏幕(如果未使用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆