d0c4182aca42956fd1a8a9345919a987407050b5
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/locale.c
23 * PURPOSE: Locale 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)
100 ret
= RegOpenKeyW(HKEY_CURRENT_USER
, L
"Control Panel\\International", &localeKey
);
102 if (ret
!= ERROR_SUCCESS
)
104 // some serious error
105 MessageBoxW(NULL
, L
"Problem opening HKCU\\Control Panel\\International key", L
"Big Problem", MB_OK
);
109 wsprintf(value
, L
"%04X", (DWORD
)lcid
);
110 valuesize
= (wcslen(value
) + 1) * sizeof(WCHAR
);
112 RegSetValueExW(localeKey
, L
"Locale", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
113 RegCloseKey(localeKey
);
116 ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language", &langKey
);
118 if (ret
!= ERROR_SUCCESS
)
120 MessageBoxW(NULL
, L
"Problem opening HKLM\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language key", L
"Big Problem", MB_OK
);
124 RegSetValueExW(langKey
, L
"Default", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
125 RegSetValueExW(langKey
, L
"InstallLanguage", 0, REG_SZ
, (BYTE
*)value
, valuesize
);
126 RegCloseKey(langKey
);
129 /* Property page dialog callback */
131 LocalePageProc(HWND hwndDlg
,
139 CreateLanguagesList(GetDlgItem(hwndDlg
, IDC_LANGUAGELIST
));
142 switch (LOWORD(wParam
))
144 case IDC_LANGUAGELIST
:
145 if (HIWORD(wParam
) == CBN_SELCHANGE
)
147 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
155 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
156 if (lpnm
->code
== (UINT
)PSN_APPLY
)
163 iCurSel
= SendMessageW(hList
,
167 if (iCurSel
== CB_ERR
)
170 NewLcid
= SendMessageW(hList
,
175 if (NewLcid
== (LCID
)CB_ERR
)
179 // Actually set new locale
180 SetNewLocale(NewLcid
);