QuakeGod
2023-10-20 6fa60de2b0d0237054aa7571191df0f291838031
提交 | 用户 | age
418cb3 1 // MyFormLog.cpp : 实现文件
Q 2 //
3
4 #include "pch.h"
5 #include "MTerm1.h"
6 #include "MyFormLog.h"
7
8
9 // CMyFormLog
10
11 IMPLEMENT_DYNCREATE(CMyFormLog, CFormView)
12
13 CMyFormLog::CMyFormLog()
14     : CFormView(CMyFormLog::IDD)
15 {
16
17 }
18
19 CMyFormLog::~CMyFormLog()
20 {
21 }
22
23 void CMyFormLog::DoDataExchange(CDataExchange* pDX)
24 {
25     CFormView::DoDataExchange(pDX);
26     DDX_Control(pDX, IDC_EDIT_LOG, m_edit_log);
27     DDX_Control(pDX, IDC_RICHEDIT2_LOG, m_richedit_log);
28 }
29
30 BEGIN_MESSAGE_MAP(CMyFormLog, CFormView)
31     ON_WM_CREATE()
32     ON_WM_DESTROY()
33     ON_WM_SIZE()
34     ON_WM_MOUSEACTIVATE()
35     ON_WM_TIMER()
36 END_MESSAGE_MAP()
37
38
39 // CMyFormLog 诊断
40
41 #ifdef _DEBUG
42 void CMyFormLog::AssertValid() const
43 {
44     CFormView::AssertValid();
45 }
46
47 #ifndef _WIN32_WCE
48 void CMyFormLog::Dump(CDumpContext& dc) const
49 {
50     CFormView::Dump(dc);
51 }
52 #endif
53 #endif //_DEBUG
54
55
56 // CMyFormLog 消息处理程序
57
58
59 BOOL CMyFormLog::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
60 {
61     // TODO: 在此添加专用代码和/或调用基类
62
63     return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
64 }
65
66
67 int CMyFormLog::OnCreate(LPCREATESTRUCT lpCreateStruct)
68 {
69     if (CFormView::OnCreate(lpCreateStruct) == -1)
70         return -1;
71
72     // TODO:  在此添加您专用的创建代码
73
74     return 0;
75 }
76
77
78 void CMyFormLog::OnDestroy()
79 {
80     CFormView::OnDestroy();
81
82     // TODO: 在此处添加消息处理程序代码
83 }
84
85
86 void CMyFormLog::OnSize(UINT nType, int cx, int cy)
87 {
88     CFormView::OnSize(nType, cx, cy);
89     // TODO: 在此处添加消息处理程序代码
90     CWnd * pwnd;
91 /*
92     pwnd=GetDlgItem(IDC_EDIT_LOG);
93     if (pwnd!=NULL)
94     {
95 //        RECT    rect1;
96         pwnd->SetWindowPos(NULL,0,0,cx,cy-20,NULL);
97     }
98 //*/
99
100 ///*
101     pwnd = GetDlgItem(IDC_RICHEDIT2_LOG);
102     if (pwnd != NULL)
103     {
104         //        RECT    rect1;
105         pwnd->SetWindowPos(NULL, 0, 0, cx, cy - 20, NULL);
106     }
107 //*/
108     pwnd=GetDlgItem(IDC_CHECK_PAUSE);
109     if (pwnd!=NULL)
110     {
111         //RECT    rect1;
112         CRect rect1;
113         pwnd->GetWindowRect(rect1);
114         ScreenToClient(&rect1);
115         pwnd->SetWindowPos(NULL,0, cy - rect1.Height()-4,rect1.Width(),rect1.Height(),NULL);
116     }
117     pwnd=GetDlgItem(IDC_CHECK_NOSCROLL);
118     if (pwnd!=NULL)
119     {
120         CRect rect1;
121         pwnd->GetWindowRect(rect1);
122         ScreenToClient(&rect1);
123         pwnd->SetWindowPos(NULL,cx-rect1.Width(),cy-rect1.Height()-4,rect1.Width(),rect1.Height(),NULL);
124     }
125 }
126
127
128 void CMyFormLog::OnInitialUpdate()
129 {
130     CFormView::OnInitialUpdate();
131     CString VersionStr = _T("V1.02");
132     CString BuildStr = _T("20210728");
133     // TODO: 在此添加专用代码和/或调用基类
134     myLogger1.SetLogPathName(_T("D:\\Logs\\MTerm1"), _T("MTerm1"));
135     myLogger1.AttachWnd(m_richedit_log.m_hWnd);
136     myLogger1.bShowLog[0] = 1;
137     myLogger1.bShowThreadId = 0;
138     myLogger1.bShowChannel = 0;
139     myLogger1.bSaveLog[0] = 1;
140     myLogger1.bShowDate = 1;
141     SysLog(_T(" Start ") + VersionStr + _T(" ") + BuildStr + _T("\r\n"));
142     myLogger1.bShowDate = 0;
143 //    myLogger1.bShowLineCount=0;
144 //    myLogger1.bShowTime=0;
145     myLogger1.UpdateLogDisplay();
146     SetTimer(1, 100, NULL);
147 }
148
149
150 int CMyFormLog::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
151 {
152     // TODO: 在此添加消息处理程序代码和/或调用默认值
153
154     return CFormView::OnMouseActivate(pDesktopWnd, nHitTest, message);
155 }
156
157
158 void CMyFormLog::OnTimer(UINT_PTR nIDEvent)
159 {
160     // TODO: 在此添加消息处理程序代码和/或调用默认值
161     if (nIDEvent == 1)
162     {
163         KillTimer(1);
164         SetTimer(2, 200, NULL);
165     }
166     else if (nIDEvent == 2)
167     {
168         myLogger1.UpdateLogDisplay();
169     }
170     else
171     {
172
173     }
174     CFormView::OnTimer(nIDEvent);
175 }