Author: ekohl
Date: Tue Sep 11 00:46:27 2007
New Revision: 28996
URL:
http://svn.reactos.org/svn/reactos?rev=28996&view=rev
Log:
- Enumerate time formats.
- The user must able to change the locale id. Move it into a global structure.
- User the selected locale id instead of LOCALE_USER_DEFAULT.
Modified:
trunk/reactos/dll/cpl/intl/currency.c
trunk/reactos/dll/cpl/intl/date.c
trunk/reactos/dll/cpl/intl/generalp.c
trunk/reactos/dll/cpl/intl/intl.h
trunk/reactos/dll/cpl/intl/misc.c
trunk/reactos/dll/cpl/intl/sort.c
trunk/reactos/dll/cpl/intl/time.c
Modified: trunk/reactos/dll/cpl/intl/currency.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/currency.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/currency.c (original)
+++ trunk/reactos/dll/cpl/intl/currency.c Tue Sep 11 00:46:27 2007
@@ -301,7 +301,7 @@
static BOOL
SetCurrencyDigNum(HWND hwndDlg)
{
- TCHAR szFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES][MAX_SAMPLES_STR_SIZE]=
+ LPTSTR szFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES]=
{
_T("0;0"),
_T("3;0"),
Modified: trunk/reactos/dll/cpl/intl/date.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/date.c?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/date.c (original)
+++ trunk/reactos/dll/cpl/intl/date.c Tue Sep 11 00:46:27 2007
@@ -540,11 +540,15 @@
WPARAM wParam,
LPARAM lParam)
{
+ PGLOBALDATA pGlobalData;
+
switch (uMsg)
{
case WM_INITDIALOG:
+ pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+
InitMinMaxDateSpin(hwndDlg);
- UpdateDateLocaleSamples(hwndDlg, LOCALE_USER_DEFAULT);
+ UpdateDateLocaleSamples(hwndDlg, pGlobalData->lcid);
InitShortDateCB(hwndDlg);
InitLongDateCB(hwndDlg);
InitShortDateSepSamples(hwndDlg);
Modified: trunk/reactos/dll/cpl/intl/generalp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/generalp.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/generalp.c (original)
+++ trunk/reactos/dll/cpl/intl/generalp.c Tue Sep 11 00:46:27 2007
@@ -235,6 +235,7 @@
}
/* Location enumerate procedure */
+#if 0
BOOL
CALLBACK
LocationsEnumProc(GEOID gId)
@@ -255,12 +256,14 @@
return TRUE;
}
+#endif
/* Enumerate all system locations identifiers */
static
VOID
CreateLocationsList(HWND hWnd)
{
+#if 0
GEOID userGeoID;
TCHAR loc[MAX_STR_SIZE];
@@ -280,6 +283,7 @@
CB_SELECTSTRING,
(WPARAM) -1,
(LPARAM)loc);
+#endif
}
DWORD
Modified: trunk/reactos/dll/cpl/intl/intl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/intl.h?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/intl.h (original)
+++ trunk/reactos/dll/cpl/intl/intl.h Tue Sep 11 00:46:27 2007
@@ -13,6 +13,11 @@
UINT idDescription;
APPLET_PROC AppletProc;
} APPLET, *PAPPLET;
+
+typedef struct _GLOBALDATA
+{
+ LCID lcid;
+} GLOBALDATA, *PGLOBALDATA;
extern HINSTANCE hApplet;
extern DWORD IsUnattendedSetupEnabled;
Modified: trunk/reactos/dll/cpl/intl/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/misc.c?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/misc.c (original)
+++ trunk/reactos/dll/cpl/intl/misc.c Tue Sep 11 00:46:27 2007
@@ -175,7 +175,7 @@
static VOID
-InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LCID lcid)
+InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBALDATA
pGlobalData)
{
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
psp->dwSize = sizeof(PROPSHEETPAGE);
@@ -183,7 +183,7 @@
psp->hInstance = hApplet;
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
psp->pfnDlgProc = DlgProc;
- psp->lParam = (LPARAM)lcid;
+ psp->lParam = (LPARAM)pGlobalData;
}
@@ -194,9 +194,15 @@
{
PROPSHEETPAGE PsPage[NUM_SHEETS + 1];
PROPSHEETHEADER psh;
+ PGLOBALDATA pGlobalData;
TCHAR Caption[MAX_STR_SIZE];
+ INT ret;
LoadString(hApplet, IDS_CUSTOMIZE_TITLE, Caption, sizeof(Caption) / sizeof(TCHAR));
+
+ pGlobalData = (PGLOBALDATA)malloc(sizeof(GLOBALDATA));
+
+ pGlobalData->lcid = lcid;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
@@ -209,18 +215,22 @@
psh.nStartPage = 0;
psh.ppsp = PsPage;
- InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, lcid);
- InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, lcid);
- InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, lcid);
- InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, lcid);
+ InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, pGlobalData);
+ InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, pGlobalData);
+ InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, pGlobalData);
+ InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, pGlobalData);
if (IsSortPageNeeded(lcid))
{
psh.nPages++;
- InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, lcid);
- }
-
- return (LONG)(PropertySheet(&psh) != -1);
+ InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, pGlobalData);
+ }
+
+ ret = PropertySheet(&psh);
+
+ free(pGlobalData);
+
+ return (LONG)(ret != -1);
}
/* EOF */
Modified: trunk/reactos/dll/cpl/intl/sort.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/sort.c?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/sort.c (original)
+++ trunk/reactos/dll/cpl/intl/sort.c Tue Sep 11 00:46:27 2007
@@ -156,14 +156,17 @@
WPARAM wParam,
LPARAM lParam)
{
+ PGLOBALDATA pGlobalData;
+
+ pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch (uMsg)
{
case WM_INITDIALOG:
- {
- LCID lcid = (LCID)((LPPROPSHEETPAGE)lParam)->lParam;
-
- CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), lcid);
- }
+ pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
+
+ CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO),
pGlobalData->lcid);
break;
case WM_COMMAND:
@@ -172,6 +175,28 @@
case IDC_SORTLIST_COMBO:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
+ LCID NewLcid;
+ INT iCurSel;
+
+ iCurSel = SendDlgItemMessage(hwndDlg,
+ IDC_SORTLIST_COMBO,
+ CB_GETCURSEL,
+ 0,
+ 0);
+ if (iCurSel == CB_ERR)
+ break;
+
+ NewLcid = SendDlgItemMessage(hwndDlg,
+ IDC_SORTLIST_COMBO,
+ CB_GETITEMDATA,
+ iCurSel,
+ 0);
+ if (NewLcid == (LCID)CB_ERR)
+ break;
+
+ /* Save the new LCID */
+ pGlobalData->lcid = NewLcid;
+
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
break;
@@ -179,34 +204,9 @@
break;
case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
{
- LPNMHDR lpnm = (LPNMHDR)lParam;
-
- if (lpnm->code == (UINT)PSN_APPLY)
- {
-
- LCID NewLcid;
- INT iCurSel;
-
- iCurSel = SendDlgItemMessage(hwndDlg,
- IDC_SORTLIST_COMBO,
- CB_GETCURSEL,
- 0,
- 0);
- if (iCurSel == CB_ERR)
- break;
-
- NewLcid = SendDlgItemMessage(hwndDlg,
- IDC_SORTLIST_COMBO,
- CB_GETITEMDATA,
- iCurSel,
- 0);
- if (NewLcid == (LCID)CB_ERR)
- break;
-#if 0
- /* FIXME: Set locale ID */
-#endif
- }
+ /* FIXME: Set locale ID: pGlobalData->lcid */
}
break;
}
Modified: trunk/reactos/dll/cpl/intl/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/time.c?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/time.c (original)
+++ trunk/reactos/dll/cpl/intl/time.c Tue Sep 11 00:46:27 2007
@@ -31,22 +31,26 @@
#include "intl.h"
#include "resource.h"
-/*
- * TODO:
- * - Enumerate available time formats (use EnumTimeFormats)
- */
+static HWND hwndEnum = NULL;
+
+static BOOL CALLBACK
+TimeFormatEnumProc(LPTSTR lpTimeFormatString)
+{
+ SendMessage(hwndEnum,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)lpTimeFormatString);
+
+ return TRUE;
+}
static VOID
-UpdateTimeSample(HWND hWnd)
+UpdateTimeSample(HWND hWnd, LCID lcid)
{
- TCHAR InBuffer[80];
- TCHAR OutBuffer[80];
-
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, InBuffer, 80);
-
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, InBuffer, OutBuffer, 80);
-
- SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)OutBuffer);
+ TCHAR szBuffer[80];
+
+ GetTimeFormat(lcid, 0, NULL, NULL, szBuffer, 80);
+ SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
@@ -57,36 +61,41 @@
WPARAM wParam,
LPARAM lParam)
{
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- TCHAR Buffer[80];
- int nLen;
+ PGLOBALDATA pGlobalData;
+
+ pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ TCHAR Buffer[80];
+ int nLen;
+
+ pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
/* Update the time format sample */
- UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE));
+ UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE), pGlobalData->lcid);
/* Get the time format (max. 80 characters) */
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
CB_LIMITTEXT, 80, 0);
- /* FIXME: add available time formats to the list */
-
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, Buffer, 80);
+ /* Add available time formats to the list */
+ hwndEnum = GetDlgItem(hwndDlg, IDC_TIMEFORMAT);
+ EnumTimeFormats(TimeFormatEnumProc, pGlobalData->lcid, 0);
+
+ GetLocaleInfo(pGlobalData->lcid, LOCALE_STIMEFORMAT, Buffer, 80);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
- CB_ADDSTRING,
- 0,
- (LPARAM)Buffer);
- SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
- CB_SETCURSEL,
- 0, /* index */
- 0);
+ CB_SELECTSTRING,
+ -1,
+ (LPARAM)Buffer);
/* Get the time separator (max. 4 characters) */
SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
CB_LIMITTEXT, 4, 0);
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIME, Buffer, 80);
+ GetLocaleInfo(pGlobalData->lcid, LOCALE_STIME, Buffer, 80);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
CB_ADDSTRING,
0,
@@ -99,7 +108,7 @@
/* Get the AM symbol (max. 9 characters) */
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
CB_LIMITTEXT, 9, 0);
- nLen = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S1159, Buffer, 80);
+ nLen = GetLocaleInfo(pGlobalData->lcid, LOCALE_S1159, Buffer, 80);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
CB_ADDSTRING,
0,
@@ -119,7 +128,7 @@
/* Get the PM symbol (max. 9 characters) */
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
CB_LIMITTEXT, 9, 0);
- nLen = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S2359, Buffer, 80);
+ nLen = GetLocaleInfo(pGlobalData->lcid, LOCALE_S2359, Buffer, 80);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
CB_ADDSTRING,
0,
@@ -168,14 +177,14 @@
CB_GETCURSEL, 0, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, Buffer);
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_STIMEFORMAT, Buffer);
/* Set time separator */
nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
CB_GETCURSEL, 0, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIME, Buffer);
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_STIME, Buffer);
/* Set the AM symbol */
nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
@@ -184,11 +193,11 @@
{
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S1159, Buffer);
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_S1159, Buffer);
}
else
{
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S1159, _T(""));
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_S1159, _T(""));
}
/* Set the PM symbol */
@@ -198,21 +207,21 @@
{
SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S2359, Buffer);
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_S2359, Buffer);
}
else
{
- SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S2359, _T(""));
+ SetLocaleInfo(pGlobalData->lcid, LOCALE_S2359, _T(""));
}
/* Update the time format sample */
- UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE));
+ UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE), pGlobalData->lcid);
}
}
break;
- }
-
- return FALSE;
+ }
+
+ return FALSE;
}
/* EOF */