// CDialogDateTime.cpp: 实现文件
|
//
|
|
#include "pch.h"
|
#include "MTerm1.h"
|
#include "DialogDateTime.h"
|
#include "afxdialogex.h"
|
//#include "KLink.h"
|
#include "MTerm1Doc.h"
|
|
// CDialogDateTime 对话框
|
|
IMPLEMENT_DYNAMIC(CDialogDateTime, CDialogEx)
|
|
CDialogDateTime::CDialogDateTime(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_DIALOG_DATETIME, pParent)
|
{
|
|
}
|
|
CDialogDateTime::~CDialogDateTime()
|
{
|
}
|
|
void CDialogDateTime::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CDialogDateTime, CDialogEx)
|
ON_BN_CLICKED(IDC_BUTTON_SUBMIT, &CDialogDateTime::OnBnClickedButtonSubmit)
|
ON_WM_TIMER()
|
END_MESSAGE_MAP()
|
|
|
// CDialogDateTime 消息处理程序
|
|
|
BOOL CDialogDateTime::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
// TODO: 在此添加额外的初始化
|
((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->SetCheck(0);
|
SetTimer(1, 300, NULL);
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
int CDialogDateTime::ShowParams()
|
{
|
// TODO: 在此处添加实现代码.
|
return 0;
|
}
|
|
|
int CDialogDateTime::UpdateDisplay()
|
{
|
// TODO: 在此处添加实现代码.
|
CString s1;
|
if (((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->GetCheck())
|
{
|
CTime time1;
|
time1 = time1.GetTickCount();
|
|
int year = time1.GetYear();
|
s1.Format(_T("%02d"), year);
|
SetDlgItemText(IDC_EDIT_YEAR, s1);
|
int mon = time1.GetMonth();
|
s1.Format(_T("%02d"), mon);
|
SetDlgItemText(IDC_EDIT_MONTH, s1);
|
int day = time1.GetDay();
|
s1.Format(_T("%02d"), day);
|
SetDlgItemText(IDC_EDIT_DAY, s1);
|
|
int hour = time1.GetHour();
|
s1.Format(_T("%02d"), hour);
|
SetDlgItemText(IDC_EDIT_HOUR, s1);
|
int min = time1.GetMinute();
|
s1.Format(_T("%02d"), min);
|
SetDlgItemText(IDC_EDIT_MINUTE, s1);
|
int sec=time1.GetSecond();
|
s1.Format(_T("%02d"), sec);
|
SetDlgItemText(IDC_EDIT_SECOND, s1);
|
}
|
return 0;
|
}
|
|
|
void CDialogDateTime::OnTimer(UINT_PTR nIDEvent)
|
{
|
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
if (nIDEvent == 1)
|
{
|
UpdateDisplay();
|
}
|
else
|
{
|
|
}
|
CDialogEx::OnTimer(nIDEvent);
|
}
|
|
|
void CDialogDateTime::OnBnClickedButtonSubmit()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
|
CView *pV = (CView*)pChild->GetActiveView();
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)(pV->GetDocument());
|
|
int year, mon, day;
|
int hour, min, sec;
|
|
year = GetDlgItemInt(IDC_EDIT_YEAR);
|
mon = GetDlgItemInt(IDC_EDIT_MONTH);
|
day = GetDlgItemInt(IDC_EDIT_DAY);
|
|
hour = GetDlgItemInt(IDC_EDIT_HOUR);
|
min = GetDlgItemInt(IDC_EDIT_MINUTE);
|
sec = GetDlgItemInt(IDC_EDIT_SECOND);
|
tm tm1;
|
tm1.tm_year = year;
|
tm1.tm_mon = mon;
|
tm1.tm_mday = day;
|
|
tm1.tm_hour = hour;
|
tm1.tm_min = min;
|
tm1.tm_sec = sec;
|
|
CTime time1(year,mon,day,hour,min,sec);
|
__time32_t time2 = (__time32_t)time1.GetTime();
|
theApp.MyKLink1.SetDateTime32(1, time2);
|
// MyKLink1.WriteDataByte(1, 4, MyKLink1.KLDataTypeSDT, 36, (unsigned char *)&time2);
|
|
}
|
|
|