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

📄 log.cpp

📁 PDA通讯网关服务器源码程序
💻 CPP
字号:
// Log.cpp : implementation file
//

#include "stdafx.h"
#include "GateAgent.h"
#include "Log.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLog dialog


CLog::CLog(CWnd* pParent /*=NULL*/)
	: CDialog(CLog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CLog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLog)
	DDX_Control(pDX, IDC_LIST_LOG, m_listLog);
	DDX_Control(pDX, IDC_DTIME_FIND, m_dTime);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLog, CDialog)
	//{{AFX_MSG_MAP(CLog)
	ON_BN_CLICKED(IDC_BTN_FIND, OnBtnFind)
	ON_BN_CLICKED(IDC_BTN_EXIT, OnBtnExit)
	ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLog message handlers

void CLog::OnBtnFind() 
{
	CString strFileName,strLineContext;	
	CTime tDate;
	CString strDate;
	m_dTime.GetTime(tDate);
	m_dTime.GetWindowText(strDate);
	CString strTmp;
	strTmp.Format("%04d%02d%02d",tDate.GetYear(),tDate.GetMonth(), tDate.GetDay());
	strFileName.Format("./log/%s.txt",strTmp);

	strTmp.Empty();
	strTmp.Format("%s的日志内容如下",strDate);
	m_listLog.DeleteColumn(0);
	m_CPubBase.OnInitGrid(&m_listLog,false,strTmp.GetBuffer(0));

	m_listLog.DeleteAllItems();  //清空

	FILE *fp;
	char line[1000]={0};

	if((fp=fopen(strFileName.GetBuffer(0),"r"))==NULL)
	{
		MessageBox(" 没有本天的日志!","提示",MB_OK);
		return ;
	}

	int i=0;
	while(!feof(fp))
	{
		fgets( line, 999, fp );  
		line[999]='\0';
		if(m_listLog.GetItemCount()>6000)
		{
			MessageBox("日志内容太多,不能完全加载!","提示",MB_OK);
			break;
		}
		m_listLog.InsertItem(i, line);

		i++;
	} 
	fclose(fp);	
}

void CLog::OnBtnExit() 
{
	CLog::OnCancel();	
}

void CLog::OnBtnDel() 
{
	m_listLog.DeleteAllItems();  //清空
}

BOOL CLog::OnInitDialog() 
{
	CDialog::OnInitDialog();	
	m_CPubBase.OnInitGrid(&m_listLog,false,"日志内容");

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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