先用
CTime time = CTime::GetCurrentTime();
int nSecond = time.GetSecond();
int nMintue = time.GetMinute();
int nHour = time.GetHour();
学的系统时间了,然后把static控件名字改为:
IDC_SHOWTIME
然后关联一个变量:control m_showTime
然后怎么把这个值传递到这个变量上去呢?
CTime time = CTime::GetCurrentTime();
int nSecond = time.GetSecond();
int nMintue = time.GetMinute();
int nHour = time.GetHour();
学的系统时间了,然后把static控件名字改为:
IDC_SHOWTIME
然后关联一个变量:control m_showTime
然后怎么把这个值传递到这个变量上去呢?
strTime.Format("%d :%d:%d:",nhour,nMintue,Nsecond);m_showTime.setwindowtext(strTime);
你看看你是是Format()里面那个地方少了个逗号.
strTime.Format("%d:%d:%d:",nhour,nMintue,nSecond);
SetDlgItemText(static控件ID,"要显示的时间");
时间有特殊的格式化的函数:看源码吧!
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的