首先:在Resourse 选项卡上面的String Table 中添加:窗格如:IDS_TIMER 时钟
其次:在MainFrame APP 文件中加入标识
如:
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
// ID_INDICATOR_CAPS,
// ID_INDICATOR_NUM,
// ID_INDICATOR_SCRL,
IDS_TIMER,
};
再次:MainFrame::OnCreate()函数中添加如下代码:
CTime t=CTime::GetCurrentTime();
CString str=t.Format("%H : %M : %S ");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);
int index=0;
index=m_wndStatusBar.CommandToIndex(IDS_TIMER);
m_wndStatusBar.SetPaneInfo(index,IDS_TIMER,SBPS_NORMAL,sz.cx);
m_wndStatusBar.SetPaneText(index,str);
最后在OnTimer()函数中添加如下代码:
状态栏的编程
CTime t=CTime::GetCurrentTime();
CString str=t.Format("%H : %M : %S ");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);
m_wndStatusBar.SetPaneInfo(1, IDS_TIMER, SBPS_NORMAL, sz.cx);
m_wndStatusBar.SetPaneText(1, str);