当前位置: 首页>>代码示例>>C++>>正文


C++ CConfigParser::Initialize方法代码示例

本文整理汇总了C++中CConfigParser::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigParser::Initialize方法的具体用法?C++ CConfigParser::Initialize怎么用?C++ CConfigParser::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConfigParser的用法示例。


在下文中一共展示了CConfigParser::Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadStats

/*
** Reads statistics.
**
*/
void CMeasureNet::ReadStats(const std::wstring& iniFile, std::wstring& statsDate)
{
	WCHAR buffer[48];

	CConfigParser parser;
	parser.Initialize(iniFile, NULL, L"Statistics");

	const std::wstring& date = parser.ReadString(L"Statistics", L"Since", L"", false);
	if (!date.empty())
	{
		statsDate = date;
	}

	uint32_t count = parser.ReadUInt(L"Statistics", L"Count", 0);
	if (parser.GetLastDefaultUsed())
	{
		count = parser.ReadUInt(L"Statistics", L"NetStatsCount", 0);
	}

	c_StatValues.clear();
	c_StatValues.reserve(count * 2);

	for (uint32_t i = 1; i <= count; ++i)
	{
		ULARGE_INTEGER value;

		_snwprintf_s(buffer, _TRUNCATE, L"In%u", i);
		value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
		if (parser.GetLastDefaultUsed())
		{
			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInHigh%u", i);
			value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);

			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInLow%u", i);
			value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
		}
		c_StatValues.push_back(value.QuadPart);

		_snwprintf_s(buffer, _TRUNCATE, L"Out%u", i);
		value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
		if (parser.GetLastDefaultUsed())
		{
			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutHigh%u", i);
			value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);

			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutLow%u", i);
			value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
		}
		c_StatValues.push_back(value.QuadPart);
	}
}
开发者ID:JamesAC,项目名称:rainmeter,代码行数:55,代码来源:MeasureNet.cpp

示例2: GetDlgItem

INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
	case IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX:
		{
			BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED);

			HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
			EnableWindow(item, state);
			Button_SetCheck(item, BST_UNCHECKED);

			item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX);
			EnableWindow(item, state);
			Button_SetCheck(item, BST_UNCHECKED);
		}
		break;

	case IDC_MANAGETHEMES_NAME_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			int len = Edit_GetText((HWND)lParam, buffer, 32);

			// Disable save button if no text or if backup
			BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0);
			EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state);
		}
		break;

	case IDC_MANAGETHEMES_LIST:
		if (HIWORD(wParam) == LBN_SELCHANGE)
		{
			// Ignore clicks that don't hit items
			if (ListBox_GetCurSel((HWND)lParam) != LB_ERR)
			{
				HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
				EnableWindow(item, TRUE);
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON);
				EnableWindow(item, TRUE);
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON);
				EnableWindow(item, TRUE);
				
				const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
				item  = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
				int sel = ListBox_GetCurSel(item);
				
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
				Edit_SetText(item, themes[sel].c_str());
			}
		}
		break;

	case IDC_MANAGETHEMES_SAVE_BUTTON:
		{
			WCHAR buffer[MAX_PATH];
			HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
			Edit_GetText(item, buffer, MAX_PATH);

			std::wstring theme = buffer;
			std::wstring path = Rainmeter->GetThemePath();
			CreateDirectory(path.c_str(), 0);

			path += theme;
			bool alreadyExists = (_waccess(path.c_str(), 0) != -1);
			if (alreadyExists)
			{
				std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str());
				if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
				{
					// Cancel
					break;
				}
			}
			else
			{
				// Make sure path exists
				CreateDirectory(path.c_str(), NULL);
			}

			path += L"\\Rainmeter.thm";

			item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX);
			if (Button_GetCheck(item) != BST_CHECKED)
			{
				if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path))
				{
					std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
					Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
					break;
				}

				// Exclude unused skins
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
				if (Button_GetCheck(item) == BST_CHECKED)
				{
					CConfigParser parser;
					parser.Initialize(path);

					// Remove sections with Active=0
//.........这里部分代码省略.........
开发者ID:JamesAC,项目名称:rainmeter,代码行数:101,代码来源:DialogManage.cpp


注:本文中的CConfigParser::Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。