1.在资源视图:
String Table--添加字符串:IDS_STATUSMESSAGE、IDS_SYSTEMTIME
2.创建全局数组:
static UINT indicators[]={IDS_STATUSMESSAGE,IDS_SYSTEMTIME};
3.添加一个类成员变量
CStatusBar m_statusbar;
4.在::OnInitDialog()中初始化:
///create the status bar and set the number of panes
if( !m_statusbar.Create(this) || !m_statusbar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)) ) return FALSE;
//size the panes
CRect m_rect;
GetClientRect(&m_rect);
m_statusbar.SetPaneInfo(0,IDS_STATUSMESSAGE,m_rect.Width()-180);
m_statusbar.SetPaneInfo(1,IDS_SYSTEMTIME,180);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,IDS_SYSTEMTIME);
//显示内容
m_statusbar.SetPaneText(0,"实时信息");
m_statusbar.SetPaneText(1,"时间");
5.在OnPaint()中显示窗口重绘的内容
Invalidate();///或UpdateWindow()进行窗口重绘