1、void 工程中视图名::OnDraw(CDC* pDC)
{
CRetertrtrDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CDC *pDC1=GetDC();
CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S"); //根据得到的当前时间格式化为字符串形式
pDC1->TextOut(100,100,strTime);
}
2、创建OnInitialUpdate()函数
void工程中视图名::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
//在View中不写对象名
SetTimer(1,1000,NULL);
}
3、因SetTimer()函数中的最后一项函数名为NULL,调用OnTimer()函数
void 工程中视图名::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDC * pDC=GetDC();
CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S"); //根据得到的当前时间格式化为字符串形式
SetDlgItemText(IDC_StaticFileName, strTime);
pDC->TextOut(100,100,strTime);
CView::OnTimer(nIDEvent);
}