Programming/MFC [에디트박스] 실시간 현재 시간 표시하기 푸어맨 2017. 5. 2. 09:14 // define #define TIMER_PC 1000 BOOL Dlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 현재 시간 표시 SetTimer(TIMER_PC, 1000, 0); return TRUE; // return TRUE unless you set the focus to a control } void Dlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add your message handler code here and/or call default switch (nIDEvent) { case TIMER_PC: CTime cTime = CTime::GetCurrentTime(); // 현재 시스템으로부터 날짜 및 시간을 얻어 온다. CString strDate, strTime; // 반환되는 날짜와 시간을 저장할 CString 변수 선언 strDate.Format(_T("%04d/%02d/%02d %02d:%02d:%02d"), cTime.GetYear(), // 현재 년도 반환 cTime.GetMonth(), // 현재 월 반환 cTime.GetDay(), // 현재 일 반환 cTime.GetHour(), // 현재 시간 반환 cTime.GetMinute(), // 현재 분 반환 cTime.GetSecond()); // 현재 초 반환 m_edit_time_pc.SetWindowTextW(strDate); break; defalut: break; } CDialogEx::OnTimer(nIDEvent); } void Dlg::OnDestroy() { CDialogEx::OnDestroy(); // TODO: Add your message handler code here KillTimer(TIMER_PC); }