From 88cd4628a06b4d1e0db01c1901f824f664bc1067 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Sun, 18 Jan 2009 11:20:32 +0000 Subject: [PATCH] - Fix bug with addition of keyboard layouts svn path=/trunk/; revision=38883 --- reactos/dll/cpl/input/add.c | 33 ++++++++++++++++++++++++++++---- reactos/dll/cpl/input/settings.c | 7 +++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/reactos/dll/cpl/input/add.c b/reactos/dll/cpl/input/add.c index eb1103741f5..5eaaddb89c8 100644 --- a/reactos/dll/cpl/input/add.c +++ b/reactos/dll/cpl/input/add.c @@ -106,15 +106,40 @@ AddNewLayout(HWND hwndDlg) return; } - if (GetLayoutName(LangID, Layout)) + if (_tcscmp(LangID, pts) != 0) { - if ((SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)Layout) != CB_ERR)&& - (GetLayoutCount(Lang) >= 1)) + if (!GetLayoutName(pts, Layout)) { - wsprintf(SubPath, _T("d%03d%s"), GetLayoutCount(Lang)-1, Lang); + RegCloseKey(hKey); + return; + } + } + else + { + if (!GetLayoutName(LangID, Layout)) + { + RegCloseKey(hKey); + return; + } + } + + if (SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)Layout) != CB_ERR) + { + if (GetLayoutCount(Lang) >= 1) + { + wsprintf(SubPath, _T("d%03d%s"), GetLayoutCount(Lang), Lang); + } + else if ((_tcscmp(LangID, pts) != 0) && (GetLayoutCount(Lang) == 0)) + { + wsprintf(SubPath, _T("d%03d%s"), 0, Lang); } else SubPath[0] = '\0'; } + else + { + RegCloseKey(hKey); + return; + } if (_tcslen(SubPath) != 0) { diff --git a/reactos/dll/cpl/input/settings.c b/reactos/dll/cpl/input/settings.c index ae578cc5859..58642f54a86 100644 --- a/reactos/dll/cpl/input/settings.c +++ b/reactos/dll/cpl/input/settings.c @@ -64,7 +64,10 @@ IsLayoutExists(LPTSTR szLayoutID, LPTSTR szLangID) GetLocaleInfo(langid, LOCALE_ILANGUAGE, szTmp, sizeof(szTmp) / sizeof(TCHAR)); wsprintf(szOldLangID, _T("0000%s"), szTmp); - if (_tcscmp(szOldLangID, szLangID) == 0) IsLangExists = TRUE; + if (_tcscmp(szOldLangID, szLangID) == 0) + IsLangExists = TRUE; + else + IsLangExists = FALSE; if (szPreload[0] == 'd') { @@ -84,7 +87,7 @@ IsLayoutExists(LPTSTR szLayoutID, LPTSTR szLangID) } else { - if (_tcscmp(szPreload, szLayoutID) == 0) + if ((_tcscmp(szPreload, szLayoutID) == 0) && (IsLangExists)) { RegCloseKey(hKey); return TRUE;