Beispiel #1
0
CMainWizard::CMainWizard(CWnd* pOwnerWnd):
CCustomPropSheet(AFX_IDS_APP_TITLE, pOwnerWnd)
{
	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	ASSERT_VALID(pApp);

	// assign CRT locale
	static const TCHAR szDefLocale[] = _T("English_USA.1252");
	_tsetlocale(LC_ALL, pApp->GetProfileString(SZ_REGK_LOCALE, SZ_REGV_LOCALE_LC_ALL, szDefLocale));

	// load dialog's icons
	m_hIcon = pApp->LoadIcon(IDI_APP_ICON);
	m_hSmIcon = pApp->LoadSmIcon(MAKEINTRESOURCE(IDI_APP_ICON));

	static HYPERLINKCOLORS linkColors =
	{
		RGB(0, 0, 255),	// default
		RGB(0, 0, 255),	// active
		RGB(0, 0, 255),	// visited
		RGB(255, 0, 0)		// hover
	};
	CHyperLink::SetColors(linkColors);

	ATL::CRegKey regKeyLangs;
	regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));

	int nError = ERROR_SUCCESS;

	if (static_cast<HKEY>(regKeyLangs) != NULL)
	{
		TCHAR szLangNames[128] = { 0 };
		ULONG cchNamesMax = _countof(szLangNames);
		nError = regKeyLangs.QueryStringValue(NULL, szLangNames, &cchNamesMax);
		if (nError == ERROR_SUCCESS)
		{
			LPCTSTR pszSeps = _T(",;\x20");
			LPTSTR pszCurLex = _tcstok(szLangNames, pszSeps);
			while (pszCurLex != NULL)
			{
				m_arrLangNames.Add(pszCurLex);
				pszCurLex = _tcstok(NULL, pszSeps);
			}
		}
		::RegCloseKey(regKeyLangs.Detach());
	}

	g_fRestartInterface = false;

	AddPage(&m_pageAbout);
	AddPage(&m_pageFirstLaunch);
	AddPage(&m_pageOptions);
	AddPage(&m_pageFiles);
	AddPage(&m_pageAction);
	AddPage(&m_pageProgress);

	SetWizardMode();
}
Beispiel #2
0
void CMainWizard::OnLanguageChange(UINT uMenuID)
{
	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	ASSERT_VALID(pApp);

	ATL::CRegKey regKeyLangs;
	regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));

	int nError = ERROR_SUCCESS;

	if (static_cast<HKEY>(regKeyLangs) != NULL)
	{
		UINT iLangName = uMenuID - ((ID_LANGUAGE_ENGLISH & 0x00F0) >> 4);
		nError = regKeyLangs.SetStringValue(SZ_REGV_LANGUAGES_CURRENT, m_arrLangNames[iLangName]);
		if (nError == ERROR_SUCCESS)
		{
			CheckLangMenuItem(iLangName);
			regKeyLangs.Flush();
			g_fRestartInterface = true;
			PostMessage(PSM_PRESSBUTTON, PSBTN_CANCEL, 0);
		}
		::RegCloseKey(regKeyLangs.Detach());
	}