也拿上个专题来说:
它使用的方法如下:
char text[100];
CMainFrame *pMainFrame=(CMainFrame *)AfxGetApp()->GetMainWnd();
wsprintf(text,"mouse.x=%d mouse.y=%d",point.x,point.y);
pMainFrame->m_wndStatusBar.SetPaneText(1,text);
pMainFrame->m_wndStatusBar.SetPaneStyle(1,SBPS_POPOUT);
我们仍然可以使用下面的方式(不过有点麻烦):创建新的状态栏
//在View类的鼠标移动函数中:
char text[100];
CStatusBar* pStatus=(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUSBAR);
if(pStatus)
{
wsprintf(text,"mouse.x=%d mouse.y=%d",point.x,point.y);
pStatus->SetPaneText(1,text);
pStatus->SetPaneStyle(1,SBPS_POPOUT);
}
// 在资源符号里添加资源标识
ID_STATUSBAR
// 在MainFrm.cpp重新创建状态栏,OnCreate()函数中:
if (!m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM,ID_STATUSBAR)||!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)))
{
TRACE0("未能创建状态栏/n");
return -1; // 未能创建
}
m_wndStatusBar.SetPaneInfo(0,ID_STATUSBAR,SBPS_POPOUT,230); //设置状态消息行的宽度
m_wndStatusBar.SetPaneInfo(1,ID_STATUSBAR,SBPS_POPOUT,230);