SetTimer OnTimer WM_TIMER

SetTimer(1, 2000, 0);

void CTest::OnTimer(UINT nIDEvent)
{
    // TODO: Add your message handler code here and/or call default
    AfxMessageBox(_T("Timer perform success!"));

    CDialog::OnTimer(nIDEvent);
}

 

需要在类中设置WM_TIMER。

在类视图中选择

class->properties->message->WM_TIMER-><add> OnTimer

在OnTimer中添加所需代码,

AfxMessageBox(_T("Timer perform success!"));

在类中需要的位置添加

SetTimer(1, 2000, 0);

 

OK

in windowsXP + vs2003

原文地址:https://www.cnblogs.com/WeRtogether/p/1563175.html