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

📄 systemconfig.cpp

📁 上传的是有关mfc的详细介绍
💻 CPP
字号:
// SystemConfig.cpp: implementation of the SystemConfig class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SystemConfig.h"

#include "MFCINi.h"

#include "ItemKey.h"

#include <cstring> 

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

SystemConfig	*SystemConfig::s_Config	=	0;

SystemConfig *SystemConfig::GetConfig()
{
	if (s_Config == 0)
	{
		s_Config = new SystemConfig;
	}
	return s_Config;
}

SystemConfig::SystemConfig()
{
	this->m_chTitle = "六子的程序";
	this->m_chLogPath = "C:\\liuzi\\log\\";
	this->m_nLogLevel = 0;
	this->m_MainRECT = new RECT;
	this->m_MainRECT->left = 200;
	this->m_MainRECT->right = 700;
	this->m_MainRECT->top = 100;
	this->m_MainRECT->bottom = 500;
	this->m_bIsDevelop = false;

	MFCINi ini;	
	CString strFileName = "SystemConfig.ini";
	bool bIsOpen = ini.Open(ItemKey::INI_FOLDER + strFileName);
	if (!bIsOpen)
	{
		return;
	}
	
	char* chTitle = ini.Read(ItemKey::CONFIG_TITLE);
	char* chLogPath = ini.Read(ItemKey::CONFIG_LOGPATH);
	this->m_chTitle = new char[strlen(chTitle) + 1];
	this->m_chLogPath = new char[strlen(chLogPath) + 1];
	strcpy(this->m_chTitle, chTitle);
	strcpy(this->m_chLogPath, chLogPath);

	char* chLevel = ini.Read(ItemKey::CONFIG_LOGLEVEL);
	sscanf(chLevel, ("%d"), &this->m_nLogLevel);	

	char* chRECT = ini.Read(ItemKey::CONFIG_MAIN_RECT);
	int nLeft	= 0;
	int	nRight	= 0;
	int	nTop	= 0;
	int	nBottom	= 0;
	sscanf(chRECT, ("%d;%d;%d;%d"), &nLeft, &nRight, &nTop, &nBottom);

	delete this->m_MainRECT;
	this->m_MainRECT			= new RECT;
	this->m_MainRECT->left		= nLeft;
	this->m_MainRECT->right		= nRight;
	this->m_MainRECT->top		= nTop;
	this->m_MainRECT->bottom	= nBottom;

	char* chBgColor = ini.Read(ItemKey::CONFIG_FORM_BGCOLOR);
	int r = 0;
	int g = 0;
	int b = 0;
	sscanf(chBgColor, ("%d,%d,%d"), &r, &g, &b);

	this->m_Color = RGB(r,g,b);

	int nIsDevelop = 0;
	char* chDevelop = ini.Read(ItemKey::CONFIG_ISDEVELOP);
	sscanf(chDevelop, ("%d"), &nIsDevelop);
	if (nIsDevelop == 1)
	{
		this->m_bIsDevelop = true;
	}
	else
	{
		this->m_bIsDevelop = false;
	}
}

SystemConfig::~SystemConfig()
{
	if (this->m_chTitle)
	{
		delete [] this->m_chTitle;
	}
	if (this->m_chLogPath)
	{
		delete [] this->m_chLogPath;
	}

	if (this->m_MainRECT)
	{
		delete this->m_MainRECT;
	}
}

⌨️ 快捷键说明

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