QuakeGod
2023-05-19 418cb35b936f21415807a2bcc21b2d75934bd4d2
提交 | 用户 | age
0ed438 1 // CDialogDateTime.cpp: 实现文件
Q 2 //
3
4 #include "pch.h"
5 #include "MTerm2.h"
65f713 6 #include "DialogDateTime.h"
0ed438 7 #include "afxdialogex.h"
Q 8 #include "KLink.h"
9 #include "MTerm2Doc.h"
10
11 // CDialogDateTime 对话框
12
13 IMPLEMENT_DYNAMIC(CDialogDateTime, CDialogEx)
14
15 CDialogDateTime::CDialogDateTime(CWnd* pParent /*=nullptr*/)
16     : CDialogEx(IDD_DIALOG_DATETIME, pParent)
17 {
18
19 }
20
21 CDialogDateTime::~CDialogDateTime()
22 {
23 }
24
25 void CDialogDateTime::DoDataExchange(CDataExchange* pDX)
26 {
27     CDialogEx::DoDataExchange(pDX);
28 }
29
30
31 BEGIN_MESSAGE_MAP(CDialogDateTime, CDialogEx)
32     ON_BN_CLICKED(IDC_BUTTON_SUBMIT, &CDialogDateTime::OnBnClickedButtonSubmit)
33     ON_WM_TIMER()
34 END_MESSAGE_MAP()
35
36
37 // CDialogDateTime 消息处理程序
38
39
40 BOOL CDialogDateTime::OnInitDialog()
41 {
42     CDialogEx::OnInitDialog();
43
44     // TODO:  在此添加额外的初始化
b5e652 45     ((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->SetCheck(0);
0ed438 46     SetTimer(1, 300, NULL);
Q 47     return TRUE;  // return TRUE unless you set the focus to a control
48                   // 异常: OCX 属性页应返回 FALSE
49 }
50
51 int CDialogDateTime::ShowParams()
52 {
53     // TODO: 在此处添加实现代码.
54     return 0;
55 }
56
57
58 int CDialogDateTime::UpdateDisplay()
59 {
60     // TODO: 在此处添加实现代码.
61     CString s1;
62     if (((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->GetCheck())
63     {
64         CTime time1;
65         time1 = time1.GetTickCount();
66
67         int year = time1.GetYear();
68         s1.Format(_T("%02d"), year);
69         SetDlgItemText(IDC_EDIT_YEAR, s1);
70         int mon = time1.GetMonth();
71         s1.Format(_T("%02d"), mon);
72         SetDlgItemText(IDC_EDIT_MONTH, s1);
73         int day = time1.GetDay();
74         s1.Format(_T("%02d"), day);
75         SetDlgItemText(IDC_EDIT_DAY, s1);
76
77         int hour = time1.GetHour();
78         s1.Format(_T("%02d"), hour);
79         SetDlgItemText(IDC_EDIT_HOUR, s1);
80         int min = time1.GetMinute();
81         s1.Format(_T("%02d"), min);
82         SetDlgItemText(IDC_EDIT_MINUTE, s1);
83         int sec=time1.GetSecond();
84         s1.Format(_T("%02d"), sec);
85         SetDlgItemText(IDC_EDIT_SECOND, s1);
86     }
87     return 0;
88 }
89
90
91 void CDialogDateTime::OnTimer(UINT_PTR nIDEvent)
92 {
93     // TODO: 在此添加消息处理程序代码和/或调用默认值
94     if (nIDEvent == 1)
95     {
96         UpdateDisplay();
97     }
98     else
99     {
100
101     }
102     CDialogEx::OnTimer(nIDEvent);
103 }
104
105
106 void CDialogDateTime::OnBnClickedButtonSubmit()
107 {
108     // TODO: 在此添加控件通知处理程序代码
109     CMDIFrameWnd  *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
110     CMDIChildWnd  *pChild = (CMDIChildWnd   *)pFrame->GetActiveFrame();
111     CView   *pV = (CView*)pChild->GetActiveView();
112     CMTerm2Doc* pDoc = (CMTerm2Doc *)(pV->GetDocument());
113
114     int year, mon, day;
115     int hour, min, sec;
116
117     year = GetDlgItemInt(IDC_EDIT_YEAR);
118     mon = GetDlgItemInt(IDC_EDIT_MONTH);
119     day = GetDlgItemInt(IDC_EDIT_DAY);
120
121     hour = GetDlgItemInt(IDC_EDIT_HOUR);
122     min = GetDlgItemInt(IDC_EDIT_MINUTE);
123     sec = GetDlgItemInt(IDC_EDIT_SECOND);
124     tm tm1;
125     tm1.tm_year = year;
126     tm1.tm_mon = mon;
127     tm1.tm_mday = day;
128
129     tm1.tm_hour = hour;
130     tm1.tm_min = min;
131     tm1.tm_sec = sec;
132
133     CTime time1(year,mon,day,hour,min,sec);
134     __time32_t time2 = (__time32_t)time1.GetTime();
135     pDoc->MyKLink1.SetDateTime32(1, time2);
136 //    MyKLink1.WriteDataByte(1, 4, MyKLink1.KLDataTypeSDT, 36, (unsigned char *)&time2);
137
138 }
139
140