方法一:采用定时器
BOOL CCountDownDlg::OnInitDialog()
{ ....
SetTimer(0, 1000, NULL);
}
void CCountDownDlg::OnTimer(UINT nIDEvent)
{ // TODO: Add your message handler code here and/or call default
if (nIDEvent == 0)
{
if (--m_nSecond)
{
CString strTemp;
strTemp.Format(m_strPrompt, m_nSecond);
SetDlgItemText(IDC_STATIC1, strTemp); }
else
{
OnOK();
}
}