创建和初始化状态栏
step1
对话框添加变量
// 状态栏对象
CStatusBarm_wndStatusBar;
step2
OnInitDialog调用
//创建和初始化状态栏
BOOLCLBDKFODlg::CreateStatusBar()
{
static UINT nIndicators[] = {
ID_CALL_STATUS
};
if (!m_wndStatusBar.Create (this))
return FALSE;
m_wndStatusBar.SetIndicators (nIndicators,1);
CRectrect;
GetClientRect(&rect);
m_wndStatusBar.SetPaneInfo(0,ID_CALL_STATUS,SBPS_NORMAL,rect.Width());
//m_wndStatusBar.GetStatusBarCtrl().SetBkColor(RGB(180,180,180));
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,ID_CALL_STATUS);
return TRUE;
}
注意在资源文件中定义ID_CALL_STATUS.
更新状态栏文本
m_wndStatusBar.SetPaneText(0,"空闲");
参考资料
CStatusBarin CDialog, SetPaneText and CTime,GetCurrentTime with VC++ Sample
To create a status bar, follow these steps:
There are three ways to update the text in a status-bar pane:
源文档 <https://msdn.microsoft.com/en-us/library/fha3tfk7.aspx>
原文地址:http://blog.csdn.net/soliddream66/article/details/44808423