1、在OnInitUpdate()中设置定时器,如果没有OnInitUpdate()就重载
void CTtView::OnInitialUpdate()
{
SetTimer(1,1000,NULL);
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
}
2、添加WM_TIMER消息
3、在OnTimer()中写语句
void CTtView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString s;
CTime t=CTime::GetCurrentTime();
s=t.Format("%H:%M:%S");
// MessageBox(s);
CClientDC dc(this);
dc.TextOut(200,2,s);//定点显示
Invalidate(FALSE); //刷新函数
CView::OnTimer(nIDEvent);
}