⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clog.cpp

📁 服务器大厅设计 VC6.0开发。利用CSocket
💻 CPP
字号:
#include "stdafx.h"
#include "common.h"
#include "serverDoc.h"
#include "CntrItem.h"
#include "serverview.h"
#include "CLog.h"

CLOG ServerLog;

CLOG::CLOG()
{
 dw_LogInfoBufferCount = 0;
}






/////向LogBuffer中加入内容
BOOL CLOG::AddLogInfoToBuffer(char *ch_ParaLogInfo)
{
  if(dw_LogInfoBufferCount>MAX_LOG_BUFFER)
  {
    WarningBox("The Log Buffer Is OverFlow!");
    return FALSE;
  }
  int int_ParaLogSize = strlen(ch_ParaLogInfo);
  char *ch_LogStr  = new char[int_ParaLogSize]; 
  char *ch_TimeStr = new char[24];
  struct tm *newtime;        //////取得这个消息的时间
  char am_pm[] = "AM";
  time_t long_time;
  time( &long_time );                
  newtime = localtime( &long_time ); 
  if( newtime->tm_hour > 12 )    strcpy( am_pm, "PM" );
  
  sprintf(ch_TimeStr,"( %d %.19s %s )", newtime->tm_year+1900,asctime( newtime ), am_pm );

  strcpy(ch_LogStr,ch_ParaLogInfo);
  
  LogInfoBuffer[dw_LogInfoBufferCount].ch_LogStr  = ch_LogStr;
  LogInfoBuffer[dw_LogInfoBufferCount].ch_TimeStr = ch_TimeStr;
  dw_LogInfoBufferCount++;
  
  
  DWORD dw_TextLength;
  
  //显示Log内容
  dw_TextLength = EditCtrl->GetTextLength();
  EditCtrl->SetSel(dw_TextLength ,dw_TextLength + int_ParaLogSize);
  EditCtrl->ReplaceSel(ch_ParaLogInfo,FALSE);
  
  //显示空格
  dw_TextLength = EditCtrl->GetTextLength();
  EditCtrl->SetSel(dw_TextLength ,dw_TextLength + 13);
  EditCtrl->ReplaceSel(" - - - - - - ",FALSE);
  
  //显示时间
  dw_TextLength = EditCtrl->GetTextLength();
  EditCtrl->SetSel(dw_TextLength ,dw_TextLength + strlen(ch_TimeStr));
  EditCtrl->ReplaceSel(ch_TimeStr,FALSE);
  
  //回车
  dw_TextLength = EditCtrl->GetTextLength();
  EditCtrl->SetSel(dw_TextLength ,dw_TextLength + 1);
  EditCtrl->ReplaceSel("\n",FALSE);
  return TRUE;
}

//////清除所有的LogBuffer……
void CLOG::ClearLogBuffer()
{
  for(DWORD dw_i=0;dw_i<dw_LogInfoBufferCount;dw_i++)
  {
    delete LogInfoBuffer[dw_i].ch_LogStr; 
    delete LogInfoBuffer[dw_i].ch_TimeStr; 
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -