diff --git a/reactos/lib/cpl/intl/de.rc b/reactos/lib/cpl/intl/de.rc index 5168f02f154..0cdb9214811 100644 --- a/reactos/lib/cpl/intl/de.rc +++ b/reactos/lib/cpl/intl/de.rc @@ -55,7 +55,7 @@ BEGIN GROUPBOX "Standardsprache", -1, 8, 11, 228, 74 ICON IDC_FLAGS, IDC_ICON1, 12, 26, 21, 20, SS_ICON LTEXT "Wählen Sie eine Sprache und Region aus welche Sie benutzen wollen:", -1, 38, 25, 193, 22 - COMBOBOX IDC_LANGUAGELIST, 39, 49, 191, 83, CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP + COMBOBOX IDC_LANGUAGELIST, 39, 49, 191, 83, CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP END diff --git a/reactos/lib/cpl/intl/en.rc b/reactos/lib/cpl/intl/en.rc index fd579b63ab3..7b9e513950e 100644 --- a/reactos/lib/cpl/intl/en.rc +++ b/reactos/lib/cpl/intl/en.rc @@ -55,7 +55,7 @@ BEGIN GROUPBOX "Primary language", -1, 8, 11, 228, 74 ICON IDC_FLAGS, IDC_ICON1, 12, 26, 21, 20, SS_ICON LTEXT "Select the primary language and region you want to use:", -1, 38, 25, 193, 22 - COMBOBOX IDC_LANGUAGELIST, 39, 49, 191, 83, CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP + COMBOBOX IDC_LANGUAGELIST, 39, 49, 191, 83, CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP END diff --git a/reactos/lib/cpl/intl/locale.c b/reactos/lib/cpl/intl/locale.c index 86eecea69bb..e183e445266 100644 --- a/reactos/lib/cpl/intl/locale.c +++ b/reactos/lib/cpl/intl/locale.c @@ -23,234 +23,68 @@ * PURPOSE: Locale property page * PROGRAMMER: Eric Kohl * Klemens Friedl + * Aleksey Bragin */ +#define WINVER 0x0501 + #include #include #include +#include + #include "intl.h" #include "resource.h" +HWND hList; -// FIXME: -// * change registry function (-> "HKCR\MIME\Database\Rfc1766") - - - -typedef struct _TZ_INFO +BOOL CALLBACK LocalesEnumProc( + LPTSTR lpLocale // locale id +) { - LONG Bias; - LONG StandardBias; - LONG DaylightBias; - SYSTEMTIME StandardDate; - SYSTEMTIME DaylightDate; -} TZ_INFO, *PTZ_INFO; + LCID lcid; + TCHAR lang[255]; + int index; -typedef struct _TIMEZONE_ENTRY -{ - struct _TIMEZONE_ENTRY *Prev; - struct _TIMEZONE_ENTRY *Next; - WCHAR Description[64]; /* 'Display' */ - WCHAR StandardName[32]; /* 'Std' */ - WCHAR DaylightName[32]; /* 'Dlt' */ - TZ_INFO TimezoneInfo; /* 'TZI' */ - ULONG Index; /* 'Index' */ -} TIMEZONE_ENTRY, *PTIMEZONE_ENTRY; + swscanf(lpLocale, L"%lx", &lcid); // maybe use wcstoul? + GetLocaleInfo(lcid, LOCALE_SLANGUAGE, lang, sizeof(lang)); + index = SendMessageW(hList, + CB_ADDSTRING, + 0, + (LPARAM)lang); -PTIMEZONE_ENTRY TimeZoneListHead = NULL; -PTIMEZONE_ENTRY TimeZoneListTail = NULL; + SendMessageW(hList, + CB_SETITEMDATA, + index, + (LPARAM)lcid); - - - -static PTIMEZONE_ENTRY -GetLargerTimeZoneEntry(DWORD Index) -{ - PTIMEZONE_ENTRY Entry; - - Entry = TimeZoneListHead; - while (Entry != NULL) - { - if (Entry->Index >= Index) - return Entry; - - Entry = Entry->Next; - } - - return NULL; + return TRUE; } static VOID -CreateTimeZoneList(VOID) +CreateLanguagesList(HWND hwnd) { + TCHAR langSel[255]; - WCHAR szKeyName[256]; - DWORD dwIndex; - DWORD dwNameSize; - DWORD dwValueSize; - LONG lError; - HKEY hZonesKey; - HKEY hZoneKey; - - PTIMEZONE_ENTRY Entry; - PTIMEZONE_ENTRY Current; - - - - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", - 0, - KEY_ALL_ACCESS, - &hZonesKey)) - return; - - dwIndex = 0; - while (TRUE) - { - dwNameSize = 256; - lError = RegEnumKeyExW(hZonesKey, - dwIndex, - szKeyName, - &dwNameSize, - NULL, - NULL, - NULL, - NULL); - if (lError != ERROR_SUCCESS && lError != ERROR_MORE_DATA) - break; - - - if (RegOpenKeyExW(hZonesKey, - szKeyName, - 0, - KEY_ALL_ACCESS, - &hZoneKey)) - break; - - - Entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TIMEZONE_ENTRY)); - if (Entry == NULL) - { - RegCloseKey(hZonesKey); - break; - } - - dwValueSize = 64 * sizeof(WCHAR); - if (RegQueryValueExW(hZonesKey, - L"Display", - NULL, - NULL, - (LPBYTE)&Entry->Description, - &dwValueSize)) - { - RegCloseKey(hZonesKey); - break; - } - - dwValueSize = 32 * sizeof(WCHAR); - if (RegQueryValueExW(hZonesKey, - L"Std", - NULL, - NULL, - (LPBYTE)&Entry->StandardName, - &dwValueSize)) - { - RegCloseKey(hZonesKey); - break; - } - - dwValueSize = 32 * sizeof(WCHAR); - if (RegQueryValueExW(hZonesKey, - L"Dlt", - NULL, - NULL, - (LPBYTE)&Entry->DaylightName, - &dwValueSize)) - { - RegCloseKey(hZonesKey); - break; - } - - dwValueSize = sizeof(DWORD); - if (RegQueryValueExW(hZonesKey, - L"Index", - NULL, - NULL, - (LPBYTE)&Entry->Index, - &dwValueSize)) - { - RegCloseKey(hZonesKey); - break; - } - - dwValueSize = sizeof(TZ_INFO); - if (RegQueryValueExW(hZonesKey, - L"TZI", - NULL, - NULL, - (LPBYTE)&Entry->TimezoneInfo, - &dwValueSize)) - { - RegCloseKey(hZonesKey); - break; - } - - RegCloseKey(hZoneKey); - - if (TimeZoneListHead == NULL && - TimeZoneListTail == NULL) - { - Entry->Prev = NULL; - Entry->Next = NULL; - TimeZoneListHead = Entry; - TimeZoneListTail = Entry; - } - else - { - Current = GetLargerTimeZoneEntry(Entry->Index); - if (Current != NULL) - { - if (Current == TimeZoneListHead) - { - /* Prepend to head */ - Entry->Prev = NULL; - Entry->Next = TimeZoneListHead; - TimeZoneListHead->Prev = Entry; - TimeZoneListHead = Entry; - } - else - { - /* Insert before current */ - Entry->Prev = Current->Prev; - Entry->Next = Current; - Current->Prev->Next = Entry; - Current->Prev = Entry; - } - } - else - { - /* Append to tail */ - Entry->Prev = TimeZoneListTail; - Entry->Next = NULL; - TimeZoneListTail->Next = Entry; - TimeZoneListTail = Entry; - } - } - - dwIndex++; - } - - RegCloseKey(hZonesKey); + hList = hwnd; + EnumSystemLocalesW(LocalesEnumProc, LCID_SUPPORTED); + // Select current locale + GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, sizeof(langSel)); // or should it be System? + + SendMessageW(hList, + CB_SELECTSTRING, + -1, + (LPARAM)langSel); } - +/* static VOID -ShowTimeZoneList(HWND hwnd) +ShowLanguagesList(HWND hwnd) { TIME_ZONE_INFORMATION TimeZoneInfo; PTIMEZONE_ENTRY Entry; @@ -281,9 +115,7 @@ ShowTimeZoneList(HWND hwnd) (WPARAM)dwIndex, 0); } - - - +*/ /* Property page dialog callback */ INT_PTR CALLBACK @@ -292,16 +124,59 @@ LocalePageProc(HWND hwndDlg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) - { - case WM_INITDIALOG: + switch(uMsg) + { + case WM_INITDIALOG: + CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST)); + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_LANGUAGELIST: + if (HIWORD(wParam) == CBN_SELCHANGE) + { + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + } + break; + } + break; - CreateTimeZoneList(); - ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST)); + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; + if (lpnm->code == PSN_APPLY) + { + // Apply changes + LCID NewLcid; + int iCurSel; + char tmp[100]; - break; - } - return FALSE; + // Acquire new value + iCurSel = SendMessageW(hList, + CB_GETCURSEL, + 0, + 0); + if (iCurSel == CB_ERR) + break; + + NewLcid = SendMessageW(hList, + CB_GETITEMDATA, + iCurSel, + 0); + + if (NewLcid == CB_ERR) + break; + + + //TOOD: Actually set new locale + + sprintf(tmp, "%x, cursel=%d", NewLcid, iCurSel); + MessageBoxA(hwndDlg, tmp, "debug", MB_OK); + } + } + break; + } + return FALSE; }