首先 需要创建一个 状态栏对象:
CStatusBar m_Statusbar; //状态栏
然后在初始化程序中
//创建状态栏 m_Statusbar.Create(this); m_Statusbar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)); CRect rect; GetWindowRect(rect); m_Statusbar.SetPaneInfo(0,ID_STAUTSTIP,SBPS_STRETCH, rect.Width()/4); m_Statusbar.SetPaneInfo(1,ID_STAUTSSPEED,SBPS_NORMAL ,rect.Width()/4); m_Statusbar.SetPaneInfo(2,ID_STAUTSPORT,SBPS_NORMAL, rect.Width()/4); m_Statusbar.SetPaneInfo(3,ID_STAUTSCOUNT,SBPS_NORMAL ,rect.Width()/4); //m_Statusbar.SetPaneText(0,"就绪"); //m_Statusbar.SetPaneText(1,"速度:0kb/s"); //m_Statusbar.SetPaneText(2,"端口:8888"); //m_Statusbar.SetPaneText(3,"连接:0"); RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);//很重要****
indicators结构体定义如下:
static UINT indicators[] = { ID_STAUTSTIP, // status line indicator ID_STAUTSSPEED, ID_STAUTSPORT, ID_STAUTSCOUNT };这里结构体中的红关联string tabel,如图:
如无关联字符串,则可以使用SetPaneText函数设置状态栏的内容
效果如下:
原文:http://blog.csdn.net/hjxyshell/article/details/43973847