bool CLangPage::OnInit() { LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) + NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE)); int index = (int)_langCombo.AddString(s); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(L"-"); _langCombo.SetCurSel(0); CObjectVector<CLangEx> langs; LoadLangs(langs); for (int i = 0; i < langs.Size(); i++) { const CLangEx &lang = langs[i]; UString name, nationalName; if (!lang.Lang.GetMessage(0, name)) name = lang.ShortName; if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty()) name += NativeLangString(nationalName); index = (int)_langCombo.AddString(name); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(lang.ShortName); if (g_LangID.CompareNoCase(lang.ShortName) == 0) _langCombo.SetCurSel(index); } return CPropertyPage::OnInit(); }
BOOL CLangPage::OnInitDialog() { CPropertyPage::OnInitDialog(); LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); UString temp = NWindows::MyLoadString(IDS_LANG_ENGLISH); NativeLangString(temp, NWindows::MyLoadString(IDS_LANG_NATIVE)); int index = (int)m_cmbLang.AddString(GetSystemString(temp)); m_cmbLang.SetItemData(index, _paths.Size()); _paths.Add(L"-"); m_cmbLang.SetCurSel(0); const FString dirPrefix = GetLangDirPrefix(); NWindows::NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt")); NWindows::NFile::NFind::CFileInfo fi; CLang lang; UString error; while (enumerator.Next(fi)) { if (fi.IsDir()) continue; const int kExtSize = 4; if (fi.Name.Len() < kExtSize) continue; unsigned pos = fi.Name.Len() - kExtSize; if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt")) continue; if (!LangOpen(lang, dirPrefix + fi.Name)) { error.Add_Space_if_NotEmpty(); error += fs2us(fi.Name); continue; } const UString shortName = fs2us(fi.Name.Left(pos)); UString s = shortName; const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH); if (eng) s = eng; const wchar_t *native = lang.Get(IDS_LANG_NATIVE); if (native) NativeLangString(s, native); index = (int)m_cmbLang.AddString(GetSystemString(s)); m_cmbLang.SetItemData(index, _paths.Size()); _paths.Add(shortName); if (g_LangID.IsEqualTo_NoCase(shortName)) m_cmbLang.SetCurSel(index); } if (!error.IsEmpty()) ::MessageBoxW(m_hWnd, error, L"Error in Lang file", MB_ICONERROR); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }