MFC C++编程的时候怎么在Label中显示当前日期时间?

2025-03-18 21:17:26
推荐回答(3个)
回答1:

void CMainrDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default

CDialog::OnTimer(nIDEvent);
CString str;
CTime theTime=CTime::GetCurrentTime();
str.Format("%02d:%02d:%02d",theTime.GetHour(),theTime.GetMinute(),theTime.GetSecond());
SetDlgItemText(IDC_STATIC_TIME,str);
}

回答2:

提示说明,不支持这个类啊,用c语言的time函数试试

回答3:

把头文件包含进去