ArticleDirectory
I have developed a preschool education software ~ I want to remind him to close it at the specified time.ProgramIt's time to rest! If he does not forcibly close it in three minutes ~? How can I get this? Thank you?
Question added:
I want to provide the completeCodeI am a beginner, and I am a winform program ~~
Drag two widgets lable and timer in a form to modify the timer attribute.
Enable = True ,
Interval = 1000 .
Keep the default ID unchanged.
Write the code in the Form class:
Const Int Closetime = 5 ; // Time when the program is closed, in seconds
Const int worktime = 10; // Time required for the pop-up window, in seconds
Int curworktime = 0 ;/ / Current Time, in seconds
Bool needexit = false; // Whether the program is closed. If not, a window is displayed.
Public form1 ()
{
Initializecomponent ();
}
Private void timereffectick (Object sender, eventargs E)
{
Curworktime ++;
If (needexit)
{
Label1.text = string. Concat ("remaining", closetime-curworktime, "seconds, close the program. ");
If (curworktime = closetime) // Close the program
{
Application. Exit ();
}
}
Else
{
Label1.text = string. Concat ("remaining", worktime-curworktime, "seconds, pop-up window. ");
If (curworktime = worktime) // The dialog box is displayed.
{
Curworktime = 0;
Needexit = true;
MessageBox. Show ("you have to rest. ");
Needexit = false;
Curworktime = 0;
}
}
}