mfc 单文档显示当前系统时间

来源:互联网 发布:浙江濮院淘宝供货地 编辑:程序博客网 时间:2024/05/22 11:35

1、在mainfrm类向导添加计时器,


2、OnCreate


3、实现


CTime time;
time=CTime::GetCurrentTime();//得到当前时间
CString s=time.Format("  %Y-%m-%d  %H:%M:%S  ");//转换时间格式


//CString s=time.Format("%H:%M:%S");//转换时间格式


//m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_STATUSBAR_PANE2),s); //显示时钟
// m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, s, FALSE), s);
CMFCRibbonBaseElement * p = m_wndStatusBar.GetExElement(0);
if (p != NULL)
{
p->SetText(s);
}
m_wndStatusBar.Invalidate (TRUE);


CFrameWndEx::OnTimer(nIDEvent);

1 0