要让状态栏显示鼠标坐标信息。可按如下步骤。
1 映射 ID_VIEW_STATUSBAR 到 CMAINFRAME.这是为了让菜单可以显示和隐藏状态栏。
void CMainFrame::OnViewStatusBar()
{
// TODO: Add your command handler code here
m_wndStatusBar.ShowWindow((m_wndStatusBar.GetStyle()&WS_VISIBLE)==0);
RecalcLayout();
}void CMainFrame::OnUpdateViewStatusBar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck((m_wndStatusBar.GetStyle()&WS_VISIBLE)!=0);
}
2增加命令ID ID_MY_STATUS_BAR
3 修改CMainFrame::OnCreat().
if (!m_wndStatusBar.Create(this,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,
ID_MY_STATUS_BAR) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}