QuakeGod
2023-05-19 418cb35b936f21415807a2bcc21b2d75934bd4d2
提交 | 用户 | age
418cb3 1 // MyDialogLog.cpp : 实现文件
Q 2 //
3
4 #include "pch.h"
5 #include "MTerm1.h"
6 #include "MyDialogLog.h"
7 #include "afxdialogex.h"
8
9
10 // CMyDialogLog 对话框
11
12 IMPLEMENT_DYNAMIC(CMyDialogLog, CDialogEx)
13
14 CMyDialogLog::CMyDialogLog(CWnd* pParent /*=NULL*/)
15     : CDialogEx(CMyDialogLog::IDD, pParent)
16 {
17
18 }
19
20 CMyDialogLog::~CMyDialogLog()
21 {
22 }
23
24 void CMyDialogLog::DoDataExchange(CDataExchange* pDX)
25 {
26     CDialogEx::DoDataExchange(pDX);
27     //    DDX_Control(pDX, IDC_EDIT_LOG, m_MyEditLog1);
28     DDX_Control(pDX, IDC_EDIT_LOG1, m_edit_log1);
29 }
30
31
32 BEGIN_MESSAGE_MAP(CMyDialogLog, CDialogEx)
33     ON_WM_SIZE()
34     ON_WM_CREATE()
35     ON_WM_TIMER()
36 END_MESSAGE_MAP()
37
38
39 // CMyDialogLog 消息处理程序
40 int CMyDialogLog::OnCreate(LPCREATESTRUCT lpCreateStruct)
41 {
42     if (CDialogEx::OnCreate(lpCreateStruct) == -1)
43         return -1;
44
45     // TODO:  在此添加您专用的创建代码
46     return 0;
47 }
48
49
50 BOOL CMyDialogLog::OnInitDialog()
51 {
52     CDialogEx::OnInitDialog();
53
54     // TODO:  在此添加额外的初始化
55     CString VersionStr = _T("V1.02");
56     CString BuildStr = _T("20210728");
57
58     myLogger1.SetLogPathName(_T("D:\\Logs\\MTerm1"), _T("MTerm1"));
59     myLogger1.AttachWnd(GetDlgItem(IDC_EDIT_LOG1)->m_hWnd);
60     myLogger1.bShowLog[0] = 1;
61     myLogger1.bShowThreadId = 0;
62     myLogger1.bShowChannel = 0;
63     myLogger1.bSaveLog[0] = 1;
64     myLogger1.bShowDate = 1;
65
66     SysLog(_T(" Start ") + VersionStr + _T(" ") + BuildStr + _T("\r\n"));
67     myLogger1.bShowDate = 0;
68
69 //    CString s1;
70 //    GetWindowText(s1);
71 //    s1.Append(_T("  ") + VersionStr + _T("  ") + BuildStr);
72 //    SetWindowText(s1);
73
74     SetTimer(1,100,NULL);
75     return TRUE;  // return TRUE unless you set the focus to a control
76     // 异常: OCX 属性页应返回 FALSE
77 }
78
79 void CMyDialogLog::OnTimer(UINT_PTR nIDEvent)
80 {
81     // TODO: 在此添加消息处理程序代码和/或调用默认值
82     if (nIDEvent==1)
83     {
84         KillTimer(1);
85         SetTimer(2,200,NULL);
86     }
87     else if (nIDEvent==2)
88     {
89         myLogger1.UpdateLogDisplay();
90     }
91     else
92     {
93
94     }
95     CDialogEx::OnTimer(nIDEvent);
96 }
97
98 void CMyDialogLog::OnSize(UINT nType, int cx, int cy)
99 {
100     CDialogEx::OnSize(nType, cx, cy);
101
102     // TODO: 在此处添加消息处理程序代码
103
104     CWnd * pwnd;
105     pwnd=GetDlgItem(IDC_EDIT_LOG1);
106     if (pwnd!=NULL)
107     {
108         //        RECT    rect1;
109         GetDlgItem(IDC_EDIT_LOG1)->SetWindowPos(NULL,0,0,cx,cy-20,NULL);
110     }
111     pwnd=GetDlgItem(IDC_CHECK_PAUSEUPDATE);
112     if (pwnd!=NULL)
113     {
114         //RECT    rect1;
115         CRect rect1;
116         GetDlgItem(IDC_CHECK_PAUSEUPDATE)->GetWindowRect(rect1);
117         ScreenToClient(&rect1);
118         GetDlgItem(IDC_CHECK_PAUSEUPDATE)->SetWindowPos(NULL,4,cy-rect1.Height()-4,rect1.Width(),rect1.Height(),NULL);
119     }
120     pwnd=GetDlgItem(IDC_CHECK_NOSCROLL);
121     if (pwnd!=NULL)
122     {
123         CRect rect1;
124         GetDlgItem(IDC_CHECK_NOSCROLL)->GetWindowRect(rect1);
125         ScreenToClient(&rect1);
126         GetDlgItem(IDC_CHECK_NOSCROLL)->SetWindowPos(NULL,cx-rect1.Width()-4,cy-rect1.Height()-4,rect1.Width(),rect1.Height(),NULL);
127     }
128 }
129