The Status Bar 狀態欄

1、The Status Bar Definition
 
 
indicator鍚勯」ID瀵瑰簲鍏崇郴
indicator的各項ID與狀態欄的對應關係如上圖所示。
 
2、The Message Line
在一個view類裏面訪問狀態欄的方法:先得到Application Object,然後到達the main frame window。具體代碼如下:
CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
CStatusBar* pStatus = &pFrame->m_wndStatusBar;
pStatus->SetPaneText(0, "message line for first pane");
3、The Status Indicator
一個indicator pane對應一個resource-supplied string,而這個string與一個update command UI message handle function組成一個Message Map項。這樣,indicator pane就可以實現顯示或者灰掉。例如:
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CAPS, OnUpdateKeyCapsLock)

void CMainFrame::OnUpdateKeyCapsLock(CCmdUI* pCmdUI)
{
    pCmdUI->Enable(::GetKeyState(VK_CAPITAL) & 1);
}
與狀態欄對應的所有update command UI message handle function在Idle進程被調用,這樣使得狀態欄好像是“實時”的。
 
4、Taking Control of the Status Bar
有兩個方面要做。
第一:添加一個ID_MY_STATUS_BAR常量(用resource symbol editor),並改寫MainFrm.cpp中的m_wndStatus.Create(this)爲m_wndStatus.Create(this, WS_CHILD|WS_VISIBLE|CBRS_BOTTOM, ID_MY_STATUS_BAR )。m_wndStatus.Create()的第三個參數默認爲AFX_IDW_STATUS_BAR。
第二:標準application framework的view菜單中允許用戶開啓或關閉狀態欄,需要在CMainFrame內添加該菜單的Message Map。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章