Returns the Time Format String in seconds () format.

Source: Internet
Author: User

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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.