MFC 定时器刷新时间

SetTimer(1,1000,NULL);

afx_msg void OnTimer(UINT nIDEvent);

void CSuperMarketsDlg::OnTimer(UINT nIDEvent) 
{
// TODO: Add your message handler code here and/or call default
SYSTEMTIME time;
GetLocalTime(&time);
int num[6];
num[0] = time.wYear;
num[1] = time.wMonth;
num[2] = time.wDay;
num[3] = time.wHour;
num[4] = time.wMinute;
num[5] = time.wSecond;
CString string[6];
for(int i = 0; i < 6; i++)
{
string[i] = numTostring(num[i]);
}


CString sdate,stime;
sdate.Format("%s年%s月%s日",string[0],string[1],string[2]);
GetDlgItem(IDC_DATE)->SetWindowText(sdate);
stime.Format("%s:%s:%s",string[3],string[4],string[5]);
GetDlgItem(IDC_TIME)->SetWindowText(stime);
}

展开阅读全文

没有更多推荐了,返回首页