// MyFormLog.cpp : ʵÏÖÎļþ // #include "pch.h" #include "MTerm1.h" #include "MyFormLog.h" // CMyFormLog IMPLEMENT_DYNCREATE(CMyFormLog, CFormView) CMyFormLog::CMyFormLog() : CFormView(CMyFormLog::IDD) { } CMyFormLog::~CMyFormLog() { } void CMyFormLog::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_LOG, m_edit_log); DDX_Control(pDX, IDC_RICHEDIT2_LOG, m_richedit_log); } BEGIN_MESSAGE_MAP(CMyFormLog, CFormView) ON_WM_CREATE() ON_WM_DESTROY() ON_WM_SIZE() ON_WM_MOUSEACTIVATE() ON_WM_TIMER() END_MESSAGE_MAP() // CMyFormLog Õï¶Ï #ifdef _DEBUG void CMyFormLog::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CMyFormLog::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG // CMyFormLog ÏûÏ¢´¦Àí³ÌÐò BOOL CMyFormLog::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // TODO: ÔÚ´ËÌí¼ÓרÓôúÂëºÍ/»òµ÷ÓûùÀà return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } int CMyFormLog::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFormView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: ÔÚ´ËÌí¼ÓÄúרÓõĴ´½¨´úÂë return 0; } void CMyFormLog::OnDestroy() { CFormView::OnDestroy(); // TODO: ÔÚ´Ë´¦Ìí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂë } void CMyFormLog::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: ÔÚ´Ë´¦Ìí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂë CString s1; CWnd * pwnd; ///* pwnd=GetDlgItem(IDC_EDIT_LOG); if (pwnd!=NULL) { // RECT rect1; pwnd->SetWindowPos(NULL,0,0,cx,cy-20,NULL); // s1.Format(_T("OnSize %d %d %d \r\n"), nType, cx, cy); // ((CEdit*)GetDlgItem(IDC_EDIT_LOG))->ReplaceSel(s1); } // */ /* pwnd = GetDlgItem(IDC_RICHEDIT2_LOG); if (pwnd != NULL) { // RECT rect1; pwnd->SetWindowPos(NULL, 0, 0, cx, cy - 20, NULL); } //*/ pwnd=GetDlgItem(IDC_CHECK_PAUSE); if (pwnd!=NULL) { //RECT rect1; CRect rect1; pwnd->GetWindowRect(rect1); ScreenToClient(&rect1); pwnd->SetWindowPos(NULL,0, cy - rect1.Height()-4,rect1.Width(),rect1.Height(),NULL); } pwnd=GetDlgItem(IDC_CHECK_NOSCROLL); if (pwnd!=NULL) { CRect rect1; pwnd->GetWindowRect(rect1); ScreenToClient(&rect1); pwnd->SetWindowPos(NULL,cx-rect1.Width(),cy-rect1.Height()-4,rect1.Width(),rect1.Height(),NULL); } } void CMyFormLog::OnInitialUpdate() { CFormView::OnInitialUpdate(); CString VersionStr = _T("V1.02"); CString BuildStr = _T("20210728"); // TODO: ÔÚ´ËÌí¼ÓרÓôúÂëºÍ/»òµ÷ÓûùÀà myLogger1.SetLogPathName(_T("D:\\Logs\\MTerm1"), _T("MTerm1")); myLogger1.AttachWnd(m_edit_log.m_hWnd); // myLogger1.AttachWnd(m_richedit_log.m_hWnd); myLogger1.bShowLog[0] = 1; myLogger1.bShowThreadId = 0; myLogger1.bShowChannel = 0; myLogger1.bSaveLog[0] = 1; myLogger1.bShowDate = 1; SysLog(_T(" Start ") + VersionStr + _T(" ") + BuildStr + _T("\r\n")); myLogger1.bShowDate = 0; // myLogger1.bShowLineCount=0; // myLogger1.bShowTime=0; myLogger1.UpdateLogDisplay(); SetTimer(1, 100, NULL); } int CMyFormLog::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ return CFormView::OnMouseActivate(pDesktopWnd, nHitTest, message); } void CMyFormLog::OnTimer(UINT_PTR nIDEvent) { // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ if (nIDEvent == 1) { KillTimer(1); SetTimer(2, 200, NULL); } else if (nIDEvent == 2) { myLogger1.UpdateLogDisplay(); } else { } CFormView::OnTimer(nIDEvent); }