1、在资源视图下的String Table中打开String Table,在其中添加 IDS_INDICATOR_NISH和IDS_INDICATOR_TIME
2、 声明:CStatusBar m_bar;
static UINT BASED_CODE indicators[]=
{
IDS_INDICATOR_NISH,
IDS_INDICATOR_TIME
};
3、在OnInitDialog中实现:
m_bar.Create(this);
m_bar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT));
CRect rect;
GetClientRect(&rect);
m_bar.SetPaneInfo(0,IDS_INDICATOR_NISH,SBPS_NORMAL,rect.Width()-100);
m_bar.SetPaneInfo(1,IDS_INDICATOR_TIME,SBPS_STRETCH,0);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,IDS_INDICATOR_NISH);
4、时钟时间:
在OnInitDialog中设置:
SetTimer(ID_TIME,1000,NULL);
void CclientDlg::OnTimer(UINT_PTR nIDEvent)
{
if(nIDEvent == ID_TIME)
{
CTime t1;
t1 = CTime::GetCurrentTime();
m_bar.SetPaneText(1,t1.Format(_T("%H:%M:%S")));
}
CDialogEx::OnTimer(nIDEvent);
}
5、设置Nish的信息:
m_bar.SetPaneText(0,socketIndicatorStr + serialIndicatorStr);