In ourProgramYou often need to set the timer. The following is a step to set the timer:
1. settimer (1, 1000, null );
2. format the answer-to-Answer timer to display as minute: Second () format time
Void cxxxdlg: formattimer ()
{
M_ianswerthemetimer ++; // Add one second
Int iminute = 0;
Int isecond = 0;
Int ianswerthemetimer = m_ianswerthemetimer;
Cstring strminute = _ T ("");
Cstring strsecond = _ T ("");
Cstring stranswerthemetimer = _ T ("");
// The total timer time is less than 3600 seconds
If (ianswerthemetimer <3600)
{
// The total timer time is less than 60 seconds
If (ianswerthemetimer <60)
{
Strminute = _ T ("00 ");
// The total timer time is less than 10 seconds
If (ianswerthemetimer <10)
{
Isecond = ianswerthemetimer;
Strsecond. Format ("% d", isecond );
Strsecond = _ T ("0") + strsecond;
}
// The total timer time is greater than 10 seconds and less than 60 seconds
Else
{
Isecond = ianswerthemetimer;
Strsecond. Format ("% d", isecond );
}
// Stranswerthemetimer = strminute + _ T (":") + strsecond;
}
// The total timer time is greater than 60 seconds and less than 3600 seconds
Else
{
Iminute = ianswerthemetimer/60;
// The total timer time is less than 10 minutes
If (iminute <10)
{
Strminute. Format ("% d", iminute );
Strminute = _ T ("0") + strminute;
}
// The total timer time is greater than 10 minutes and less than 60 minutes
Else
{
Strminute. Format ("% d", iminute );
}
Isecond = ianswerthemetimer-iminute * 60;
// The total timer time is less than 10 seconds
If (isecond <10)
{
Strsecond. Format ("% d", isecond );
Strsecond = _ T ("0") + strsecond;
}
// The total timer time is greater than 10 seconds and less than 60 seconds
Else
{
Strsecond. Format ("% d", isecond );
}
// Stranswerthemetimer = strminute + _ T (":") + strsecond;
}
Stranswerthemetimer = strminute + _ T (":") + strsecond;
M_ctranswerthemetimer.setwindowtext (stranswerthemetimer );
}
Else
{
M_ianswerthemetimer = 0;
}
}
3. killtimer (1 );
More TechnologiesArticleSee Shi Changquan's personal website: http://www.joyvc.cn