读书人

mfc 的编辑框中如何显示系统的当前时间

发布时间: 2012-01-26 19:40:46 作者: rapoo

mfc 的编辑框中怎么显示系统的当前时间啊
如题!!!
CTime theTime;
theTime = CTime::GetCurrentTime();
取得时间, 但是怎么显示出来呢


[解决办法]
CTime theTime;
theTime = CTime::GetCurrentTime();
CString str;
str.Format( "%d-%d-%d %d:%d:%d ",
theTime.GetYear(), theTime.GetMonth(), theTime.GetDay(),
theTime.GetHour(), theTime.GetMinute(), theTime.GetSecond());
[解决办法]
再调用 SetDlgItemText 把 str 设置到编译框中.
[解决办法]
最简单的方法:

CString m_strTime ;
CTime theTime;
theTime = CTime::GetCurrentTime();
m_strTime =theTime.Format( "%Y/%m/%d %H:%M:%S ");//Format注意大小写!!

再将m_strTime 显示到编辑框即可

读书人网 >VC/MFC

热点推荐