?? logfunctions.cpp
字號:
#include "stdafx.h"
#include "LogFunctions.h"
void LogMessage(CRichEditCtrl* richEditCtrl, BOOL status, const char* message, BOOL logToFile, CFile* logFile)
{
CString logMessage;
CString timeString;
CTime time;
CHARFORMAT cf;
richEditCtrl->GetDefaultCharFormat(cf);
cf.dwMask = CFM_COLOR;
cf.dwEffects = 0;
if (status)
{
cf.crTextColor = RGB(0, 0, 0);
}
else
{
cf.crTextColor = RGB(255, 0, 0);
}
// Obtain the current time and create a string for the log
time = CTime::GetCurrentTime();
timeString = time.Format("%H:%M:%S");
// Create the log string with the time, error if needed and the message
logMessage.Format("%s - %s%s\r\n", timeString, (status ? "" : "ERROR: "), message);
// Set Focus to auto scroll the Richedit window and update it
richEditCtrl->SetFocus();
richEditCtrl->SetSel(0xFFFF, 0xFFFF);
richEditCtrl->HideSelection(FALSE, TRUE);
richEditCtrl->SetSelectionCharFormat(cf);
richEditCtrl->ReplaceSel(logMessage);
richEditCtrl->HideSelection(TRUE, TRUE);
// If we are logging to file, put the message in the file as well
if (logToFile && (logFile->m_hFile != (UINT)INVALID_HANDLE_VALUE))
{
logFile->Write(logMessage.GetBuffer(1), logMessage.GetLength());
logMessage.ReleaseBuffer();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -