#define WM_UPDATE_LOG (WM_USER + 1)
void CDlgStepControl::LogMessage(const CString& message)
{
DWORD threadId = GetCurrentThreadId();
SYSTEMTIME timeCur;
GetLocalTime(&timeCur);
char t_logbuffer[1024] = { 0 };
sprintf_s(t_logbuffer, "[%04d-%02d-%02d %02d:%02d:%02d:%03d][线程ID%d]",
timeCur.wYear, timeCur.wMonth, timeCur.wDay,
timeCur.wHour, timeCur.wMinute, timeCur.wSecond, timeCur.wMilliseconds, threadId);
CString fullMessage;
fullMessage.Format(_T("%s %s\r\n"), CString(t_logbuffer), message);
EnterCriticalSection(&m_csLog);
m_strLog += fullMessage;
int nline = m_strLog.GetLength() - m_strLog.Replace(_T("\r\n"), _T(""));
if (nline >= 100)
{
m_strLog = "";
}
PostMessage(WM_UPDATE_LOG);
if (pMain->m_NodeInfo.m_bEnableLog)
{
}
LeaveCriticalSection(&m_csLog);
}
LRESULT CDlgStepControl::OnUpdateLog(WPARAM wParam, LPARAM lParam)
{
m_editLog.SetWindowText(m_strLog);
int nline = m_editLog.GetLineCount();
m_editLog.LineScroll(nline - 1);
return 0;
}
DWORD WINAPI LogWriteThread(LPVOID lpParam)
{
CDlgStepControl* pDlg = (CDlgStepControl*)lpParam;
while (true)
{
}
return 0;
}