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

📄 display.cpp

📁 FTP上传工具,FTP上传的小例子,包括定制时间上传功能
💻 CPP
字号:
// Display.cpp: implementation of the CDisplay class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FtpServer.h"
#include "Display.h"
#include "FtpServerDlg.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDisplay::CDisplay()
{
	Start=0;
	Lines=0;

	
}

CDisplay::~CDisplay()
{

}
void CDisplay::PrintMsg(char* pszMsg,enum enMsgTYPE emtype)
{
	CFtpServerDlg * MsgDlg=(CFtpServerDlg *)AfxGetApp()->m_pMainWnd;
	//if(m_bEndDlg) return;
	m_nPrintCounts++;
	if(MsgDlg->m_bCheck_ShowTime)
	{
		_snprintf(m_szPrintBuf,512,"[%s] %s\n",CTime::GetCurrentTime().Format("%d-%m %H:%M:%S"),pszMsg);
	}
	else
	{
		_snprintf(m_szPrintBuf,512,"%s\n",pszMsg);
	}

	if(m_dwPrintLines>=1000)
	{
		m_dwPrintLines=0;
		m_dwPrintMsgLen=0;
		MsgDlg->m_listbox.ResetContent();
	}
	switch(emtype)
	{
	case INFOMSG:
		if(!MsgDlg->m_bCheck_Normal) return;
		MsgDlg->m_listbox.AddString(m_szPrintBuf,RGB(0,0,0));
		break;
	case WARNMSG:
		if(!MsgDlg->m_bCheck_Warn) return;
		MsgDlg->m_listbox.AddString(m_szPrintBuf,RGB(0,0,200));
		break;
	case ERRORMSG:
		if(!MsgDlg->m_bCheck_Error) return;
		MsgDlg->m_listbox.AddString(m_szPrintBuf,RGB(200,0,0));
		break;
	}
	m_dwPrintLines++;
	_snprintf(m_szPrintBuf,512,"%s\n",pszMsg);
	WriteMsg(m_szPrintBuf);
	
}

void CDisplay::Full(char *str)
{
	sprintf(str,"%s\n",str);
	CFtpServerDlg * MsgDlg=(CFtpServerDlg *)AfxGetApp()->m_pMainWnd;
	if(Lines>=100)
   {
	   Lines=0;
	   Start=0;
	   MsgDlg->m_listbox.ResetContent();
   }
	
//	MsgDlg->m_EditCustom.SetSel(Start,Start);
//	MsgDlg->m_EditCustom.ReplaceSel(str);
	Start+=strlen(str);
	Lines=Lines++;
}

int CDisplay::WriteMsg(char* pszMsg,BYTE nType)
{
	if(pszMsg==NULL)
		return 0;
	char szFile[125]={0};
	switch(nType)
	{
	case 0:
		strcpy(szFile,"FtpLog.txt");
		break;
	case 1:
		strcpy(szFile,"FtpError.txt");
		break;
	default:
		strcpy(szFile,"FtpLog.txt");
	}
	FILE* pf=fopen(szFile,"a+");
	if(pf)
	{
		CTime mytime=CTime::GetCurrentTime();
		fwrite(mytime.Format("%Y-%m-%d %H:%M:%S"),1,strlen(mytime.Format("%Y-%m-%d %H:%M:%S")),pf);
		fwrite(pszMsg,1,strlen(pszMsg),pf);
		fwrite("\n",1,1,pf);
		fclose(pf);
	}
	return 0;
}


⌨️ 快捷键说明

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