void CTest0318Dlg::OnBnClickedButton1()
{
int timer = SetTimer(1, 1000, NULL);
MSG msg;
while (true)
{
if (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (count == 20)
{
KillTimer(timer);
break;
}
}
}
void CTest0318Dlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
count++;
CString str;
str.Format(_T("%d"), count);
GetDlgItem(IDC_EDIT1)->SetWindowTextW(str);
CDialogEx::OnTimer(nIDEvent);
}