如何在计时器的帮助下最小化未使用的表格(无事件) [英] how to minimize unused form(no event) with the help of timer

查看:106
本文介绍了如何在计时器的帮助下最小化未使用的表格(无事件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在开发vb.net中的地址簿。我已经开发了它,但现在我想在不使用超过一分钟时自动最小化我的表格。

请帮帮我。

谢谢

Hello,
I am developing address book in vb.net. I have developed it, but now i want to minimize my form automatically when it is not used for more than one minute.
Please help me out.
Thanks

推荐答案

在表单中添加一个计时器。

将计时器Interval设置为1000(或以毫秒为单位),并添加一个Tick事件处理程序

添加一个类级私有整数并将其设置为60 - 将其命名为inactiveTime

在Tick处理程序中,检查inactiveTime的值。如果它为零,则什么也不做。

否则,将其减1。如果它现在为零,则将窗体WindowState设置为FormWindowState.Minimized

每当用户执行任何您计为活动的事情时,将inactiveTime设置回60.
Add a Timer to your form.
Set the timer Interval to 1000 (or one second in milliseconds) and add a Tick event handler
Add a class level private integer and set it to 60 - call it inactiveTime
In the Tick handler, check the value of inactiveTime. If it is zero, do nothing.
Otherwise, decrement it by one. If it is now zero, set the form WindowState to FormWindowState.Minimized
Whenever the user does anything you count as activity, set inactiveTime back to 60.


这篇关于如何在计时器的帮助下最小化未使用的表格(无事件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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