Implement the time format page for the regional settings control panel.
Modified: trunk/reactos/lib/cpl/intl/de.rc
Modified: trunk/reactos/lib/cpl/intl/en.rc
Modified: trunk/reactos/lib/cpl/intl/resource.h
Modified: trunk/reactos/lib/cpl/intl/time.c

Modified: trunk/reactos/lib/cpl/intl/de.rc
--- trunk/reactos/lib/cpl/intl/de.rc	2005-04-24 10:37:17 UTC (rev 14791)
+++ trunk/reactos/lib/cpl/intl/de.rc	2005-04-24 14:49:56 UTC (rev 14792)
@@ -34,7 +34,25 @@
 CAPTION "Uhrzeit"
 FONT 8, "MS Shell Dlg"
 BEGIN
-  LTEXT "Property Page 4",-1,73,74,90,8
+  GROUPBOX "Darstellung", -1, 7, 7, 228, 33, WS_CHILD | WS_VISIBLE
+  LTEXT "Beispiel:", -1, 13, 21, 54, 10, WS_CHILD |WS_VISIBLE | WS_GROUP
+  EDITTEXT IDC_TIMESAMPLE, 68, 19, 84, 14, ES_READONLY | WS_CHILD | WS_VISIBLE | WS_GROUP
+  LTEXT "&Zeitformat:", -1, 13, 52, 54, 10, WS_CHILD |WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEFORMAT, 68, 50, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "&Trennzeichen:", -1, 13, 70, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMESEPARATOR, 68, 68, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "Symbol f³r &Vormittag:", -1, 13, 88, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEAMSYMBOL, 68, 86, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "Symbol f³r &Nachmittag:", -1, 13, 106, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEPMSYMBOL, 68, 104, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  GROUPBOX "", -1, 7, 132, 228, 88, WS_VISIBLE
+  LTEXT "Zeitformat\n\n"
+        "h = Stunde    m = Minute    s = Sekunde    t = Vor-/Nachmittag\n\n"
+        "h = 12 Stunden\n"
+        "H = 24 Stunden\n\n"
+        "hh, mm, ss = f³hrende Null\n"
+        "h, m, s = keine f³hrende Null",
+        -1, 13, 141, 214, 74, WS_CHILD |WS_VISIBLE | WS_GROUP
 END
 
 

Modified: trunk/reactos/lib/cpl/intl/en.rc
--- trunk/reactos/lib/cpl/intl/en.rc	2005-04-24 10:37:17 UTC (rev 14791)
+++ trunk/reactos/lib/cpl/intl/en.rc	2005-04-24 14:49:56 UTC (rev 14792)
@@ -34,7 +34,25 @@
 CAPTION "Time"
 FONT 8, "MS Shell Dlg"
 BEGIN
-  LTEXT "Property Page 4",-1,73,74,90,8
+  GROUPBOX "Appearance sample", -1, 7, 7, 228, 33, WS_CHILD | WS_VISIBLE
+  LTEXT "Time sample:", -1, 13, 21, 54, 10, WS_CHILD |WS_VISIBLE | WS_GROUP
+  EDITTEXT IDC_TIMESAMPLE, 68, 19, 84, 14, ES_READONLY | WS_CHILD | WS_VISIBLE | WS_GROUP
+  LTEXT "&Time format:", -1, 13, 52, 54, 10, WS_CHILD |WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEFORMAT, 68, 50, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "Time &separator:", -1, 13, 70, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMESEPARATOR, 68, 68, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "A&M symbol:", -1, 13, 88, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEAMSYMBOL, 68, 86, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  LTEXT "&PM symbol:", -1, 13, 106, 54, 10, WS_VISIBLE | WS_GROUP
+  COMBOBOX IDC_TIMEPMSYMBOL, 68, 104, 84, 100, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
+  GROUPBOX "", -1, 7, 132, 228, 88, WS_VISIBLE
+  LTEXT "Time format notation\n\n"
+        "h = hour    m = minute    s = second    t = am or pm\n\n"
+        "h = 12 hour\n"
+        "H = 24 hour\n\n"
+        "hh, mm, ss = leading zero\n"
+        "h, m, s = no leading zero",
+        -1, 13, 141, 214, 74, WS_CHILD |WS_VISIBLE | WS_GROUP
 END
 
 
@@ -52,7 +70,7 @@
 CAPTION "Input Locale"
 FONT 8, "MS Shell Dlg"
 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
   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 | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP

Modified: trunk/reactos/lib/cpl/intl/resource.h
--- trunk/reactos/lib/cpl/intl/resource.h	2005-04-24 10:37:17 UTC (rev 14791)
+++ trunk/reactos/lib/cpl/intl/resource.h	2005-04-24 14:49:56 UTC (rev 14792)
@@ -3,16 +3,23 @@
 
 
 #define IDC_CPLICON		1
-#define IDC_FLAGS               2
-#define IDC_ICON1               3
+#define IDC_FLAGS		2
+#define IDC_ICON1		3
 
 #define IDD_GENERALPAGE		100
 #define IDD_NUMBERSPAGE		101
 #define IDD_CURRENCYPAGE	102
+
 #define IDD_TIMEPAGE		103
+#define IDC_TIMESAMPLE		107
+#define IDC_TIMEFORMAT		108
+#define IDC_TIMESEPARATOR	109
+#define IDC_TIMEAMSYMBOL	110
+#define IDC_TIMEPMSYMBOL	111
+
 #define IDD_DATEPAGE		104
 #define IDD_LOCALEPAGE		105
-#define IDC_LANGUAGELIST        106
+#define IDC_LANGUAGELIST	106
 
 #define IDS_CPLNAME		1000
 #define IDS_CPLDESCRIPTION	1001

Modified: trunk/reactos/lib/cpl/intl/time.c
--- trunk/reactos/lib/cpl/intl/time.c	2005-04-24 10:37:17 UTC (rev 14791)
+++ trunk/reactos/lib/cpl/intl/time.c	2005-04-24 14:49:56 UTC (rev 14792)
@@ -16,8 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id$
- *
+/*
  * PROJECT:         ReactOS International Control Panel
  * FILE:            lib/cpl/intl/time.c
  * PURPOSE:         Time property page
@@ -31,19 +30,187 @@
 #include "intl.h"
 #include "resource.h"
 
+/*
+ * TODO:
+ *    - Enumerate available time formats (use EnumTimeformatsW)
+ */
 
+static VOID
+UpdateTimeSample(HWND hWnd)
+{
+  WCHAR InBuffer[80];
+  WCHAR OutBuffer[80];
+
+  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, InBuffer, 80);
+
+  GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, InBuffer, OutBuffer, 80);
+
+  SendMessageW(hWnd, WM_SETTEXT, 0, (LPARAM)OutBuffer);
+}
+
+
 /* Property page dialog callback */
 INT_PTR CALLBACK
 TimePageProc(HWND hwndDlg,
-	     UINT uMsg,
-	     WPARAM wParam,
-	     LPARAM lParam)
+             UINT uMsg,
+             WPARAM wParam,
+             LPARAM lParam)
 {
   switch(uMsg)
   {
     case WM_INITDIALOG:
+      {
+        WCHAR Buffer[80];
+        int nLen;
+
+        /* Update the time format sample */
+        UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE));
+
+        /* Get the time format (max. 80 characters) */
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
+                    CB_LIMITTEXT, 80, 0);
+
+        /* FIXME: add available time formats to the list */
+
+        GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, Buffer, 80);
+        SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
+                     CB_ADDSTRING,
+                     0,
+                     (LPARAM)Buffer);
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
+                    CB_SETCURSEL,
+                    0, /* index */
+                    0);
+
+        /* Get the time separator (max. 4 characters) */
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
+                    CB_LIMITTEXT, 4, 0);
+        GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIME, Buffer, 80);
+        SendMessageW(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
+                     CB_ADDSTRING,
+                     0,
+                     (LPARAM)Buffer);
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMESEPARATOR),
+                    CB_SETCURSEL,
+                    0, /* index */
+                    0);
+
+        /* Get the AM symbol (max. 9 characters) */
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                    CB_LIMITTEXT, 9, 0);
+        nLen = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S1159, Buffer, 80);
+        SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                     CB_ADDSTRING,
+                     0,
+                     (LPARAM)Buffer);
+        if (nLen != 0)
+        {
+          SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                       CB_ADDSTRING,
+                       0,
+                       (LPARAM)L"");
+        }
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                    CB_SETCURSEL,
+                    0, /* index */
+                    0);
+
+        /* Get the PM symbol (max. 9 characters) */
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                    CB_LIMITTEXT, 9, 0);
+        nLen = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S2359, Buffer, 80);
+        SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                     CB_ADDSTRING,
+                     0,
+                     (LPARAM)Buffer);
+        if (nLen != 0)
+        {
+          SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                       CB_ADDSTRING,
+                       0,
+                       (LPARAM)L"");
+        }
+        SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                    CB_SETCURSEL,
+                    0, /* index */
+                    0);
+      }
       break;
+
+    case WM_COMMAND:
+      switch (LOWORD(wParam))
+      {
+        case IDC_TIMEFORMAT:
+        case IDC_TIMESEPARATOR:
+        case IDC_TIMEAMSYMBOL:
+        case IDC_TIMEPMSYMBOL:
+          if (HIWORD(wParam) == CBN_SELCHANGE ||
+              HIWORD(wParam) == CBN_EDITCHANGE)
+          {
+            PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+          }
+          break;
+      }
+      break;
+
+    case WM_NOTIFY:
+      {
+        LPNMHDR lpnm = (LPNMHDR)lParam;
+
+        if (lpnm->code == PSN_APPLY)
+        {
+          WCHAR Buffer[80];
+          int nIndex;
+
+          /* Set time format */
+          nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
+                               CB_GETCURSEL, 0, 0);
+          SendMessage(GetDlgItem(hwndDlg, IDC_TIMEFORMAT),
+                      CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
+          SetLocaleInfoW(LOCALE_USER_DEFAULT, 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);
+          SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIME, Buffer);
+
+          /* Set the AM symbol */
+          nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                               CB_GETCURSEL, 0, 0);
+          if (nIndex != CB_ERR)
+          {
+            SendMessage(GetDlgItem(hwndDlg, IDC_TIMEAMSYMBOL),
+                        CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
+            SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S1159, Buffer);
+          }
+          else
+          {
+            SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S1159, L"");
+          }
+
+          /* Set the PM symbol */
+          nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                               CB_GETCURSEL, 0, 0);
+          if (nIndex != CB_ERR)
+          {
+            SendMessage(GetDlgItem(hwndDlg, IDC_TIMEPMSYMBOL),
+                        CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)Buffer);
+            SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S2359, Buffer);
+          }
+          else
+          {
+            SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_S2359, L"");
+          }
+
+          /* Update the time format sample */
+          UpdateTimeSample(GetDlgItem(hwndDlg, IDC_TIMESAMPLE));
+        }
+      }
+      break;
   }
+
   return FALSE;
 }