ribbon界面状态栏显示鼠标坐标
2011-07-06 21:11
302 查看
实现功能:在ribbon界面下,打开图像,鼠标在图像上移动时,状态栏上实时显示鼠标所在位置的坐标。方法:
在mainframe类中添加如下函数:
在里面添加如下代码:
在mainframe类中添加如下函数:
void CMainFrame::UpdateStatusBar(int nID, CString str) { CMFCRibbonBaseElement* pPane = m_wndStatusBar.FindByID(nID); if (pPane != NULL) { pPane->SetText(str); } m_wndStatusBar.Invalidate(); m_wndStatusBar.UpdateWindow(); }
void CMainFrame::UpdateUI(CFancyView* pCurrView, CString point) { UpdateStatusBar(ID_STATUSBAR_PANE1, point); }在OnCreate函数里改把相应的语句改为:
m_wndStatusBar.AddDynamicElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE1, strTitlePane1, TRUE,NULL,_T("x=0000,y=0000")));在view类中,用classwizard添加WM_MOUSEMOVE消息,然后在view中出现了void CFancyView::OnMouseMove(UINT nFlags, CPoint point)
在里面添加如下代码:
CFancyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); int offsetX = GetScrollPos(SB_HORZ); int offsetY = GetScrollPos(SB_VERT); point.x = point.x + offsetX; // 处理Zoom和滚动条的位置 point.y = point.y + offsetY; strmouse.Format("x=%d,y=%d",point.x,point.y); ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this,strmouse); CScrollView::OnMouseMove(nFlags, point);这样就可以了。
相关文章推荐
- 在使用Ribbon的MFC程序状态栏中显示鼠标坐标值
- 在使用Ribbon的MFC程序状态栏中显示鼠标坐标值
- 获取鼠标在Picture控件中的坐标,并显示到对话框的状态栏中
- [求助]关于在状态栏显示自定义坐标系下鼠标指针所在位置坐标的问题
- MFC:在状态栏最左边显示鼠标当前的坐标
- 随鼠标移动在状态栏显示地图坐标(转载)
- 随鼠标移动在状态栏显示地图坐标
- 在状态栏中显示鼠标位置坐标
- MFC中状态栏显示鼠标坐标位置
- Ribbon界面状态栏信息显示及添加进度条
- flex4.7 在IE界面显示鼠标位置的经纬度坐标值
- mfc编程时相让鼠标的坐标显示在状态栏上
- 获取鼠标在Picture控件中的坐标,并显示到对话框的状态栏中
- 获取鼠标在Picture控件中的坐标,并显示到对话框的状态栏中
- 为鼠标移动事件添加新的功能-在状态栏显示鼠标坐标
- 随鼠标移动在状态栏显示地图坐标(转载)
- MFC:在状态栏最左边显示鼠标当前的坐标
- MFC 在状态栏显示当前鼠标坐标
- 百度地图开发 随着鼠标移动在状态栏显示鼠标中心的坐标
- 在状态栏中显示鼠标坐标