在Ribbon下没有CStatusBar,怎么更新呢?我在网上搜了半天也没找到结果,到国外的网站也看了看,有几个可能有结果的还没屏蔽了,无语中。。。后来又找MSDN,在运气的帮助下,找到了一个方法,我不知道这个方法有没有什么副作用,不过至少要求的功能实现了。好了,直接上代码。
在View类中实现OnMouseMove(UINT nFlags, CPoint point),其中代码如下:
CString str;
str.Format("鼠标指针的当前坐标(X:%d, Y:%d)", point.x, point.y);
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CMFCRibbonStatusBar* statusBar = (CMFCRibbonStatusBar*)&pFrame->m_wndStatusBar;
statusBar->SetInformation(str);
在这里使用了CMFCRibbonStatusBar::SetInformation,成功。
void SetInformation(LPCTSTR lpszInfo);
Remarks:Use this method to put the status bar in the information mode. In this mode, the status bar hides all panes and displays the information string specified bylpszInfo.
When lpszInfo is NULL, the status bar reverts to regular mode.
本文介绍了如何在基于Ribbon风格的C++程序中通过自定义View类实现鼠标移动事件监听,进而动态更新状态栏文本信息。详细展示了通过CMFCRibbonStatusBar类的方法SetInformation来实现实时显示鼠标当前位置坐标的功能。
724

被折叠的 条评论
为什么被折叠?



