3 * Copyright (C) 2004, 2005 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS International Control Panel
22 * FILE: lib/cpl/intl/generalp.c
23 * PURPOSE: General property page
24 * PROGRAMMER: Eric Kohl
42 BOOL CALLBACK
LocalesEnumProc(
43 LPTSTR lpLocale
// locale id
50 //swscanf(lpLocale, L"%lx", &lcid); // maybe use wcstoul?
51 lcid
= wcstoul(lpLocale
, NULL
, 16);
53 GetLocaleInfo(lcid
, LOCALE_SLANGUAGE
, lang
, sizeof(lang
));
55 index
= SendMessageW(hList
,
70 CreateLanguagesList(HWND hwnd
)
75 EnumSystemLocalesW(LocalesEnumProc
, LCID_SUPPORTED
);
77 // Select current locale
78 GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE
, langSel
, sizeof(langSel
)); // or should it be System and not user?
87 void SetNewLocale(LCID lcid
)
89 // HKCU\\Control Panel\\International\\Locale = 0409 (type=0)
90 // HKLM,"SYSTEM\CurrentControlSet\Control\NLS\Language","Default",0x00000000,"0409" (type=0)
91 // HKLM,"SYSTEM\CurrentControlSet\Control\NLS\Language","InstallLanguage",0x00000000,"0409" (type=0)
102 ret
= GetLocaleInfoW(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_IDEFAULTCODEPAGE
, (WORD
*)OEMPage
, sizeof(OEMPage
));
105 MessageBoxW(NULL
, L
"Problem reading OEM code page", L
"Big Problem", MB_OK
);
109 GetLocaleInfoW(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_IDEFAULTANSICODEPAGE
, (WORD
*)ACPPage
, sizeof(ACPPage
));
112 MessageBoxW(NULL
, L
"Problem reading ANSI code page", L
"Big Problem", MB_OK
);
116 ret
= RegOpenKeyW(HKEY_CURRENT_USER
, L
"Control Panel\\International", &localeKey
);
118 if (ret
!= ERROR_SUCCESS
)
120 // some serious error
121 MessageBoxW(NULL
, L
"Problem opening HKCU\\Control Panel\\International key", L
"Big Problem", MB_OK
);
125 wsprintf(value
, L
"%04X", (DWORD
)lcid
);
126 valuesize
= (wcslen(value
) + 1) * sizeof(WCHAR
);
128 RegSetValueExW(localeKey
, L
"Locale", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
129 RegCloseKey(localeKey
);
131 ret
= RegOpenKeyW(HKEY_USERS
, L
".DEFAULT\\Control Panel\\International", &localeKey
);
133 if (ret
!= ERROR_SUCCESS
)
135 // some serious error
136 MessageBoxW(NULL
, L
"Problem opening HKU\\.DEFAULT\\Control Panel\\International key", L
"Big Problem", MB_OK
);
140 wsprintf(value
, L
"%04X", (DWORD
)lcid
);
141 valuesize
= (wcslen(value
) + 1) * sizeof(WCHAR
);
143 RegSetValueExW(localeKey
, L
"Locale", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
144 RegCloseKey(localeKey
);
147 ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language", &langKey
);
149 if (ret
!= ERROR_SUCCESS
)
151 MessageBoxW(NULL
, L
"Problem opening HKLM\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language key", L
"Big Problem", MB_OK
);
155 RegSetValueExW(langKey
, L
"Default", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
156 RegSetValueExW(langKey
, L
"InstallLanguage", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
158 RegCloseKey(langKey
);
162 ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage", &langKey
);
164 if (ret
!= ERROR_SUCCESS
)
166 MessageBoxW(NULL
, L
"Problem opening HKLM\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage key", L
"Big Problem", MB_OK
);
170 RegSetValueExW(langKey
, L
"OEMCP", 0, REG_SZ
, (BYTE
*)OEMPage
, (wcslen(OEMPage
) +1 ) * sizeof(WCHAR
) );
171 RegSetValueExW(langKey
, L
"ACP", 0, REG_SZ
, (BYTE
*)ACPPage
, (wcslen(ACPPage
) +1 ) * sizeof(WCHAR
) );
173 RegCloseKey(langKey
);
177 /* Property page dialog callback */
179 GeneralPageProc(HWND hwndDlg
,
187 CreateLanguagesList(GetDlgItem(hwndDlg
, IDC_LANGUAGELIST
));
190 switch (LOWORD(wParam
))
192 case IDC_LANGUAGELIST
:
193 if (HIWORD(wParam
) == CBN_SELCHANGE
)
195 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
203 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
204 if (lpnm
->code
== (UINT
)PSN_APPLY
)
211 iCurSel
= SendMessageW(hList
,
215 if (iCurSel
== CB_ERR
)
218 NewLcid
= SendMessageW(hList
,
223 if (NewLcid
== (LCID
)CB_ERR
)
227 // Actually set new locale
228 SetNewLocale(NewLcid
);