先用
CTime time = CTime::GetCurrentTime();
int nSecond = time.GetSecond();
int nMintue = time.GetMinute();
int nHour   = time.GetHour();
学的系统时间了,然后把static控件名字改为:
 IDC_SHOWTIME
然后关联一个变量:control  m_showTime
然后怎么把这个值传递到这个变量上去呢?

解决方案 »

  1.   

    CString strTime;
    strTime.Format("%d :%d:%d:",nhour,nMintue,Nsecond);m_showTime.setwindowtext(strTime);
      

  2.   

    老大:提示的这个错误:error C2661: 'Format' : no overloaded function takes 4 parameters
      

  3.   

    我刚才在我机器上调试还通过了呀!
    你看看你是是Format()里面那个地方少了个逗号.
      

  4.   

    CString strTime;
    strTime.Format("%d:%d:%d:",nhour,nMintue,nSecond);
    SetDlgItemText(static控件ID,"要显示的时间");
      

  5.   

    查了些资料,做出来了:
    时间有特殊的格式化的函数:看源码吧!
    void CProDlg::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    // 显示系统实时时间
    CTime time = CTime::GetCurrentTime();
             CString strDate = time.Format("%A, %B %d, %Y");
    CString strTime = time.Format("%H:%M:%S");
    CString str = strDate+ "\r\n"+strTime;
    GetDlgItem(IDC_SHOWTIME)->SetWindowText(str);
    }
    还要在初始化函数中调用SetTimer,良好的编程风格还需要在OnClose或者OnDestroy中调用
    KillTimer函数自己删除这个timer的