对状态栏的操作,发现源代码并不能在VS2010编译通过,原因是VS2010中部分类被更换,我就在状态栏上显示鼠标坐标进行显示。
void CTestView::OnMouseMove(UINT nFlags, CPoint point)
{
CString str;
CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
CStatusBar* pStatus = &pFrame->m_wndStatusBar;
if (pStatus)
{
str.Format("x = %d", point.x);
pStatus->SetPaneText(0, str);
str.Format("y = %d", point.y);
pStatus->SetPaneText(1, str);
}
}
错误在“CStatusBar* pStatus = &pFrame->m_wndStatusBar;“在VS2010中CStatusBar被换成了CMFCStatusBar,且m_wndStatusBar访问权限被更换成protected;小菜做了部分更改,更改如下:
void CTestView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CString str;
CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
CMFCStatusBar* pStatus = (CMFCStatusBar*)pFrame-> GetDescendantWindow(ID_MY_STATUS_BAR);
// CMFCStatusBar* pStatus = pFrame->GetStatusBar();
if (pStatus)
{
str.Format(_T("x = %d"), point.x);
pStatus->SetPaneText(0, str);
str.Format(_T("y = %d"), point.y);
pStatus->SetPaneText(1, str);
}
CView::OnMouseMove(nFlags, point);
}
// GetStatusBar自己写的函数就是返回&m_wndStatusBar
<from : http://blog.csdn.net/naruto12345/article/details/6676685>
所有评论(0)