龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

通过例程分析状态条用法(3)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
6在类CmainFrame中重载函数OnTimer(),并添加如下代码: void CMainFrame::OnTimer(UINT nIDEvent) { file:// TODO: Add your message handler code here and/or call default if(nIDEvent==1){ if(st

  <6>在类CmainFrame中重载函数OnTimer(),并添加如下代码:

  void CMainFrame::OnTimer(UINT nIDEvent)
   {
    file:// TODO: Add your message handler code here and/or call default
    if(nIDEvent==1){
     if(str.IsEmpty()) str=str1;
      str=str.Right(str.GetLength()-2);
      m_wndStatusBar.SetPaneText(1,str);
    }
    if(nIDEvent==2){
     SYSTEMTIME t;
     ::GetLocalTime(&t);
     CString str2;
     str2.Format("%d:%d:%d:%d",t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
     m_wndStatusBar.SetPaneText(3,str2);
   }
   CFrameWnd::OnTimer(nIDEvent);
  }
 

  <7>将MainFrm.h中,定义m_wndStatusBar之前的 protected: 改为public:

  <8>通过类向导在类CmystatusView中重载WM_MOUSEMOVE,并在实现函数中添加如下代码:

  void CMystatusView::OnMouseMove(UINT nFlags, CPoint point)
  {
   // TODO: Add your message handler code here and/or call default
   CString str3;
   str3.Format("X:%d,Y:%d",point.x,point.y);
   ((CMainFrame*)AfxGetMainWnd())->m_wndStatusBar.SetPaneText(2,str3);
    CView::OnMouseMove(nFlags, point);
  }
 

好了,到这里我们所有的功能就都实现了,快编译运行一下吧!怎么样?还满意吗?

收藏文章
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
评论内容为空!
还没有评论,快来抢沙发吧!
按钮 内容不能为空!
立刻说两句吧! 查看0条评论
精彩图集

赞助商链接