(1)在狀态欄資源中添加一個窗格。實作的方法是打開MainFrm.cpp檔案,找到靜态數
組indicators的定義,在第一個數組元素ID_SEPARATOR後面增加一個新的數組元素,即
添加了一個新的窗格,為了表明這個窗格的用途,故命名為
ID_INDICATOR_MOUSE_POS。修改後的代碼如下:
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_MOUSE_POS, //滑鼠位置坐标值窗格
ID_INDICATOR_CAPS, // 大寫
ID_INDICATOR_NUM, // 數字鍵
ID_INDICATOR_SCRL, // 滾動
};
(2) 在ResourceView的String Table中添加ID_INDICATOR_MOUSE_POS, 在Caption
中輸入“滑鼠的目前坐标”。

(3)添加滑鼠移動消息的響應函數。
編輯其代碼如下:
void CMyTextOutView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString szCoordinate;
//獲得狀态欄的指針
CStatusBar* pStatusBar=(CStatusBar*)GetParentFrame()->
GetDescendantWindow(ID_VIEW_STATUS_BAR);
szCoordinate.Format("(%4d,%4d)",point.x,point.y);
//在狀态欄的第二個窗格中輸出目前滑鼠位置
pStatusBar->SetPaneText(1,szCoordinate); //面闆編号從0開始
CView::OnMouseMove(nFlags, point);
}
(4)運作效果如下: