Started implementing Locale property page of intl.cpl appltet. It
already provides choices for locale, the only thing it doesn't do -
actually set chosen locale. Also it doesn't work under ReactOS.
Modified: trunk/reactos/lib/cpl/intl/de.rc
Modified: trunk/reactos/lib/cpl/intl/en.rc
Modified: trunk/reactos/lib/cpl/intl/locale.c
_____
Modified: trunk/reactos/lib/cpl/intl/de.rc
--- trunk/reactos/lib/cpl/intl/de.rc 2005-04-10 19:44:11 UTC (rev
14582)
+++ trunk/reactos/lib/cpl/intl/de.rc 2005-04-10 21:01:13 UTC (rev
14583)
@@ -55,7 +55,7 @@
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
_____
Modified: trunk/reactos/lib/cpl/intl/en.rc
--- trunk/reactos/lib/cpl/intl/en.rc 2005-04-10 19:44:11 UTC (rev
14582)
+++ trunk/reactos/lib/cpl/intl/en.rc 2005-04-10 21:01:13 UTC (rev
14583)
@@ -55,7 +55,7 @@
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
_____
Modified: trunk/reactos/lib/cpl/intl/locale.c
--- trunk/reactos/lib/cpl/intl/locale.c 2005-04-10 19:44:11 UTC (rev
14582)
+++ trunk/reactos/lib/cpl/intl/locale.c 2005-04-10 21:01:13 UTC (rev
14583)
@@ -23,234 +23,68 @@
* PURPOSE: Locale property page
* PROGRAMMER: Eric Kohl
* Klemens Friedl
+ * Aleksey Bragin
*/
+#define WINVER 0x0501
+
#include <windows.h>
#include <commctrl.h>
#include <cpl.h>
+#include <stdio.h>
+
#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;
+ hList = hwnd;
+ EnumSystemLocalesW(LocalesEnumProc, LCID_SUPPORTED);
- 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);
-
+ // 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,10 +115,8 @@
(WPARAM)dwIndex,
0);
}
+*/
-
-
-
/* Property page dialog callback */
INT_PTR CALLBACK
LocalePageProc(HWND hwndDlg,
@@ -292,16 +124,59 @@
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;
}