在状态栏添加时间显示

1.我在string   tab中添加了一个New   String,在此定义为ID_INDICATOR_CLOCK,将其  
  Caption设为00:00:00  
  2.在static   UINT   indicators[]   =  
    {  
    ID_SEPARATOR,    
    ID_INDICATOR_CLOCK,//添加  
    ID_INDICATOR_CAPS,  
    ID_INDICATOR_NUM,  
    ID_INDICATOR_SCRL,  
    }  
  3.在void   CMainFrame::OnTimer(UINT   nIDEvent)    
    {//   TODO:   Add   your   message   handler   code   here   and/or   call   default  
    CTime   time;  
    time=CTime::GetCurrentTime();  
    CString   s=time.Format(″%H:%M:%S″);  
    m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK),s);   //显示时钟  
    CFrameWnd::OnTimer(nIDEvent);  
  }  
  4.可是在状态栏没有显示时间why?

我知道了。呵呵。下面是从CSDN中摘出来的东西。Faint!搞了我好久。  
   
  The   following   procedure   shows   how   to   use   an   update   handler   function   to   display   text   in   a   pane.  
   
  To   make   a   pane   display   text    
   
  Add   a   command   update   handler   for   the   command.    
  You   can’t   use   ClassWizard   to   write   a   handler   for   a   status   bar   pane,   so   manually   add   a   prototype   for   the   handler,   as   shown   here   for   ID_INDICATOR_PAGE   (in   MAINFRM.H):  
   
  afx_msg   void   OnUpdatePage(CCmdUI   *pCmdUI);  
   
  In   the   appropriate   .CPP   file,   add   the   handler’s   definition,   as   shown   here   for   ID_INDICATOR_PAGE   (in   MAINFRM.CPP):  
   
  void   CMainFrame::OnUpdatePage(CCmdUI   *pCmdUI)  
  {  
          pCmdUI->Enable();    
  }  
   
  In   the   appropriate   message   map,   add   the   ON_UPDATE_COMMAND_UI   macro   (outside   the   “{{AFX”   comments),   as   shown   here   for   ID_INDICATOR_PAGE   (in   MAINFRM.CPP):  
   
  ON_UPDATE_COMMAND_UI(ID_INDICATOR_PAGE,   OnUpdatePage)  
   
  Add   code   to   the   handler   to   display   your   text.    
  For   ID_INDICATOR_PAGE,   expand   the   OnUpdatePage   handler   from   step   1   above,   adding   the   last   three   lines:  
   
  void   CMainFrame::OnUpdatePage(CCmdUI   *pCmdUI)    
  {  
          pCmdUI->Enable();    
          CString   strPage;  
          strPage.Format(   "Page   %d",   m_nPage   );    
          pCmdUI->SetText(   strPage   );    
  }  
   
  呵呵。原来我按照你的步骤做了好久,还设置了类型什么的。也没有 结果 。你在MSDN中查找Status   Bars:   Updating   the   Text   of   a   Status-Bar   Pane就明白了。  
   
  你在状态条中增加了一个Pane后,还要手工给它添加的处理程序,它上面的字串 才能 显示出来。   
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值