QuakeGod
2022-07-22 fc8a81d80e32cdafdae319cf439145db6613c793
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// CDialogDateTime.cpp: 实现文件
//
 
#include "pch.h"
#include "MTerm2.h"
#include "DialogDateTime.h"
#include "afxdialogex.h"
#include "KLink.h"
#include "MTerm2Doc.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();
    CMTerm2Doc* pDoc = (CMTerm2Doc *)(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();
    pDoc->MyKLink1.SetDateTime32(1, time2);
//    MyKLink1.WriteDataByte(1, 4, MyKLink1.KLDataTypeSDT, 36, (unsigned char *)&time2);
 
}