用VC写一个在Title上显示当前的时间,精确到毫秒

解决方案 »

  1.   

    SetTimer
    然后在OnTimer里边SetWindowText。
      

  2.   

    SetWindowText(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
      

  3.   

    //头文件定义
    struct timeb current_time;
    CString strTime;
    char * timeline;
    //cpp文件
    OnTimer(UINT nIDEvent) 
    {
    ftime(&current_time);
    timeline = ctime( & ( current_time.time ) );
    strTime.Format("%.8s.%03d", timeline+11, current_time.millitm);
    m_timeico.myfun(strTime);
    this->SetWindowText(strTime);  //显示时间到毫秒
    } OnInitDialog() 里 :SetTimer(0,100,NULL);
      

  4.   

    windows抢占式的线程调度原理决定了你显示的毫秒是不准确的.
    不知道你干什么要显示这个不准确的毫秒:到秒就比较准确了!
      

  5.   

    BOOL CXXX::OnInitDialog()
    {
       ...
       SetTimer(1,1000,0); //设定一秒更新一次
    }void CXXX::OnTimer(UINT_PTR nIDEvent)
    {
       if (nIDEvent = 1)
       {
          CTime tm;
          CString strTime;
          tm = CTime::GetCurrentTime();
          strTime = tm.Format("%H:%M:%S");
          // 在EDIT控件上显示出来
          SetWindowText(strTime);
       }
    }
      

  6.   

    直接在窗口的Frame中重载OnUpdateFrameTitle函数在其中添加代码this->SetWindowText(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
      

  7.   

    比如你的窗体类叫CMyWindow
    在窗体类的声明中加入一个函数的声明:
    class CMyWindow : public CDialog
    {
    ……
    void OnTimer(UINT_PTR nIDEvent);
    ……
    };在初始化函数中写入:BOOL CMyWindow::OnInitDialog()
    {
    SetTimer( 1, USER_TIMER_MINIMUM, NULL );
    }然后在消息映射表示加入:BEGIN_MESSAGE_MAP(CMyWindow, CDialog)
    ……
    ON_WM_TIMER()
    ……
    END_MESSAGE_MAP()最后实现OnTimer函数:
    void CMyWindow::OnTimer(UINT_PTR nIDEvent)
    {
    if (nIDEvent = 1)
    {
    SYSTEMTIME systm;
    GetSystemTime( &systm );
    CString strTime;
    strTime.Format( _T("%02d : %02d : %02d : %04d"), systm.wHour,
    systm.wMinute, systm.wSecond, systm.wMilliseconds );
    SetWindowText( strTime );
    }
    }就可以了
      

  8.   

    在工具Mocrosoft Visual C++中,当你想新建一工程的时候点击菜单“File”—"New"会弹出New对话框,此时有4个标签分别为Files\Project\Workspace\Other Documents,针对本题,我应该选择哪项,选中某一个标签后,又该选择什么呢,毕竟每一个标签下边都有很多的选项,小弟愚笨,望前辈赐教!
      

  9.   

    选Project,MFC应用程序,对话框还没入门,就像实现什么功能,你太浮躁了。先从语言的基础学起吧。
      

  10.   

    谢谢啊,实在是不是我急噪,是礼拜一就要交这个东西,而现在接触时间不到4天,我是搞java的,对这个还没有怎么接触。还是很感谢你。