mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 17:11:35 +00:00
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.
svn path=/trunk/; revision=14583
This commit is contained in:
parent
810d009783
commit
7bbf6258d7
|
@ -55,7 +55,7 @@ BEGIN
|
||||||
GROUPBOX "Standardsprache", -1, 8, 11, 228, 74
|
GROUPBOX "Standardsprache", -1, 8, 11, 228, 74
|
||||||
ICON IDC_FLAGS, IDC_ICON1, 12, 26, 21, 20, SS_ICON
|
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
|
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
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ BEGIN
|
||||||
GROUPBOX "Primary language", -1, 8, 11, 228, 74
|
GROUPBOX "Primary language", -1, 8, 11, 228, 74
|
||||||
ICON IDC_FLAGS, IDC_ICON1, 12, 26, 21, 20, SS_ICON
|
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
|
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
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,234 +23,68 @@
|
||||||
* PURPOSE: Locale property page
|
* PURPOSE: Locale property page
|
||||||
* PROGRAMMER: Eric Kohl
|
* PROGRAMMER: Eric Kohl
|
||||||
* Klemens Friedl
|
* Klemens Friedl
|
||||||
|
* Aleksey Bragin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define WINVER 0x0501
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <cpl.h>
|
#include <cpl.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
HWND hList;
|
||||||
|
|
||||||
// FIXME:
|
BOOL CALLBACK LocalesEnumProc(
|
||||||
// * change registry function (-> "HKCR\MIME\Database\Rfc1766")
|
LPTSTR lpLocale // locale id
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TZ_INFO
|
|
||||||
{
|
{
|
||||||
LONG Bias;
|
LCID lcid;
|
||||||
LONG StandardBias;
|
TCHAR lang[255];
|
||||||
LONG DaylightBias;
|
int index;
|
||||||
SYSTEMTIME StandardDate;
|
|
||||||
SYSTEMTIME DaylightDate;
|
|
||||||
} TZ_INFO, *PTZ_INFO;
|
|
||||||
|
|
||||||
typedef struct _TIMEZONE_ENTRY
|
swscanf(lpLocale, L"%lx", &lcid); // maybe use wcstoul?
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
GetLocaleInfo(lcid, LOCALE_SLANGUAGE, lang, sizeof(lang));
|
||||||
|
|
||||||
|
index = SendMessageW(hList,
|
||||||
|
CB_ADDSTRING,
|
||||||
|
0,
|
||||||
|
(LPARAM)lang);
|
||||||
|
|
||||||
PTIMEZONE_ENTRY TimeZoneListHead = NULL;
|
SendMessageW(hList,
|
||||||
PTIMEZONE_ENTRY TimeZoneListTail = NULL;
|
CB_SETITEMDATA,
|
||||||
|
index,
|
||||||
|
(LPARAM)lcid);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
CreateTimeZoneList(VOID)
|
CreateLanguagesList(HWND hwnd)
|
||||||
{
|
{
|
||||||
|
TCHAR langSel[255];
|
||||||
|
|
||||||
WCHAR szKeyName[256];
|
hList = hwnd;
|
||||||
DWORD dwIndex;
|
EnumSystemLocalesW(LocalesEnumProc, LCID_SUPPORTED);
|
||||||
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);
|
|
||||||
|
|
||||||
|
// Select current locale
|
||||||
|
GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, sizeof(langSel)); // or should it be System?
|
||||||
|
|
||||||
|
SendMessageW(hList,
|
||||||
|
CB_SELECTSTRING,
|
||||||
|
-1,
|
||||||
|
(LPARAM)langSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static VOID
|
static VOID
|
||||||
ShowTimeZoneList(HWND hwnd)
|
ShowLanguagesList(HWND hwnd)
|
||||||
{
|
{
|
||||||
TIME_ZONE_INFORMATION TimeZoneInfo;
|
TIME_ZONE_INFORMATION TimeZoneInfo;
|
||||||
PTIMEZONE_ENTRY Entry;
|
PTIMEZONE_ENTRY Entry;
|
||||||
|
@ -281,9 +115,7 @@ ShowTimeZoneList(HWND hwnd)
|
||||||
(WPARAM)dwIndex,
|
(WPARAM)dwIndex,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Property page dialog callback */
|
/* Property page dialog callback */
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
|
@ -292,16 +124,59 @@ LocalePageProc(HWND hwndDlg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
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();
|
case WM_NOTIFY:
|
||||||
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
|
{
|
||||||
|
LPNMHDR lpnm = (LPNMHDR)lParam;
|
||||||
|
if (lpnm->code == PSN_APPLY)
|
||||||
|
{
|
||||||
|
// Apply changes
|
||||||
|
LCID NewLcid;
|
||||||
|
int iCurSel;
|
||||||
|
char tmp[100];
|
||||||
|
|
||||||
break;
|
// Acquire new value
|
||||||
}
|
iCurSel = SendMessageW(hList,
|
||||||
return FALSE;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue