1.我在string tab中添加了一个New String,在此定义为ID_INDICATOR_CLOCK,将其
Caption设为00:00:00
2.在static UINT indicators[] =
{
ID_SEPARATOR,
ID_INDICATOR_CLOCK,//添加
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
}
3.在void CMainFrame::OnTimer(UINT nIDEvent)
{// TODO: Add your message handler code here and/or call default
CTime time;
time=CTime::GetCurrentTime();
CString s=time.Format(″%H:%M:%S″);
m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK),s); //显示时钟
CFrameWnd::OnTimer(nIDEvent);
}
4.可是在状态栏没有显示时间why?
我知道了。呵呵。下面是从CSDN中摘出来的东西。Faint!搞了我好久。
The following procedure shows how to use an update handler function to display text in a pane.
To make a pane display text
Add a command update handler for the command.
You can’t use ClassWizard to write a handler for a status bar pane, so manually add a prototype for the handler, as shown here for ID_INDICATOR_PAGE (in MAINFRM.H):
afx_msg void OnUpdatePage(CCmdUI *pCmdUI);
In the appropriate .CPP file, add the handler’s definition, as shown here for ID_INDICATOR_PAGE (in MAINFRM.CPP):
void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
}
In the appropriate message map, add the ON_UPDATE_COMMAND_UI macro (outside the “{{AFX” comments), as shown here for ID_INDICATOR_PAGE (in MAINFRM.CPP):
ON_UPDATE_COMMAND_UI(ID_INDICATOR_PAGE, OnUpdatePage)
Add code to the handler to display your text.
For ID_INDICATOR_PAGE, expand the OnUpdatePage handler from step 1 above, adding the last three lines:
void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
CString strPage;
strPage.Format( "Page %d", m_nPage );
pCmdUI->SetText( strPage );
}
呵呵。原来我按照你的步骤做了好久,还设置了类型什么的。也没有
结果
。你在MSDN中查找Status Bars: Updating the Text of a Status-Bar Pane就明白了。
你在状态条中增加了一个Pane后,还要手工给它添加的处理程序,它上面的字串
才能
显示出来。