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);