config.cpp

来自「一个集成的文本阅读工具」· C++ 代码 · 共 115 行

CPP
115
字号
// Config.cpp: implementation of the CConfig class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TipReader.h"
#include "Config.h"

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

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

CConfig::CConfig()
{
}

CConfig::~CConfig()
{

}

void CConfig::Serialize(CArchive &ar)
{
	if(ar.IsLoading())
	{
		CString fname;
		ar>>this->m_path;
		ar>>this->m_filename;
		ar>>this->m_poision;
		ar>>this->m_txtcolor;
		ar>>this->m_bkgcolor;

		LOGFONT m_logfont;
		ar.Read((BYTE *)(&m_logfont),sizeof(LOGFONT));
		this->m_font.CreateFontIndirect(&m_logfont);

		int length,i;
		POSITION psn;
		CString str;		
		ar>>length;
		if(length!=0)
		{
			this->m_pathlist.RemoveAll();
			ar>>str;
			psn=this->m_pathlist.AddHead(str);
			for(i=1;i<length;i++)
			{
				ar>>str;
				psn=m_pathlist.InsertAfter(psn,str);
			}
		}
	}
	else
	{
		LOGFONT m_logfont;
		this->m_font.GetLogFont(&m_logfont);
		ar<<this->m_path;
		ar<<this->m_filename;
		ar<<this->m_poision;
		ar<<this->m_txtcolor;
		ar<<this->m_bkgcolor;

		ar.Write((BYTE *)(&m_logfont),sizeof(LOGFONT));

		int length,i;
		length=this->m_pathlist.GetCount();
		ar<<length;
		for(i=0;i<length;i++)
		{
			ar<<this->m_pathlist.GetAt(this->m_pathlist.FindIndex(i));
		}
	}

}

BOOL CConfig::InsertPath(CString path)
{
	int length,i;
	length=this->m_pathlist.GetCount();
	for(i=0;i<length;i++)
	{
		if(path==this->m_pathlist.GetAt(this->m_pathlist.FindIndex(i)))
			break;
	}
	if(i==length)
	{
		this->m_pathlist.InsertAfter(this->m_pathlist.FindIndex(length-1),path);
		return TRUE;
	}
	return FALSE;
}

BOOL CConfig::RemovePath(CString path)
{
	int length,i;
	length=this->m_pathlist.GetCount();
	for(i=0;i<length;i++)
	{
		if(path==this->m_pathlist.GetAt(this->m_pathlist.FindIndex(i)))
			break;
	}
	if(i!=length)
	{
		this->m_pathlist.RemoveAt(this->m_pathlist.FindIndex(i));
		return TRUE;
	}
	return FALSE;
}

⌨️ 快捷键说明

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