关于在状态栏显示时间遇到一点问题
我 新建的MFC是单文档应用程序
定义了字符串资源IDS_TIMER
我在CMainFrame::OnCreate中添加了以下代码
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar); CTime t=CTime::GetCurrentTime();
CString str=t.Format("%H:%M:%S");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);
int index=0;
index=m_wndStatusBar.CommandToIndex(IDS_TIMER);
m_wndStatusBar.SetPaneInfo(index,IDS_TIMER,SBPS_NORMAL,sz.cx);
m_wndStatusBar.SetPaneText(index,str);在
static UINT indicators[] =
{
ID_SEPARATOR,           // status line indicator
IDS_TIMER,              //这里也添加了IDS_TIMER
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
运行后 在状态栏目的右下角 多了一个显示时间的窗格
但是窗格里面并没有显示时间 这是为什么呀?
谢谢大家帮忙咯

解决方案 »

  1.   

    ouyh12345(五岭散人)
         在计时器函数里,写状态栏
    可以给个例子没。上面我写的那个人家编得 有可以得~~~~
      

  2.   

    ON_UPDATE_COMMAND_UI(IDS_TIMER,OnUpdateTimer)
    再加个Onupdatetimer函数,在里面画
    显示实时时间还要在ontimer里加重绘消息
      

  3.   

    第一没有重绘。
    第二就是显示了又有什么用,你只调用了一次CTime::GetCurrentTime();只会得到此时的时间,这个时间值又不会变化
      

  4.   

    第一步:
    在OnCreate里面加上:
    //设置发WM_TIMER的时间间隔
    SetTimer(1,1000,NULL);第二步:
    BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_TIMER()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()第三步:
    static UINT indicators[] =
    {

    ID_INDICATOR_CLOCKS,
    };第四步: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_CLOCKS),s);
    CFrameWnd::OnTimer(nIDEvent);
    }第五步:
    添加一个字符串
    ID_INDICATOR_CLOCKS,值为00:00:00