Enable automatic adjustment of daylight savings changes.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 11 Nov 2004 12:24:56 +0000 (12:24 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 11 Nov 2004 12:24:56 +0000 (12:24 +0000)
svn path=/trunk/; revision=11616

reactos/lib/cpl/timedate/De.rc
reactos/lib/cpl/timedate/En.rc
reactos/lib/cpl/timedate/resource.h
reactos/lib/cpl/timedate/timedate.c
reactos/lib/syssetup/resource.h
reactos/lib/syssetup/syssetup_Cz.rc
reactos/lib/syssetup/syssetup_De.rc
reactos/lib/syssetup/syssetup_En.rc
reactos/lib/syssetup/syssetup_Fr.rc
reactos/lib/syssetup/wizard.c

index 92fe37c..715f3b6 100644 (file)
@@ -29,7 +29,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 5, 4, 241, 136,
              CBS_DROPDOWNLIST | WS_VSCROLL | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "&Uhr automatisch auf Sommer-/Winterzeit umstellen",
-                 IDC_AUTOADJUST, 5, 136, 241, 10, WS_VISIBLE | WS_GROUP | WS_TABSTOP
+                 IDC_AUTODAYLIGHT, 5, 136, 241, 10, WS_VISIBLE | WS_GROUP | WS_TABSTOP
 END
 
 
index 8ae7000..01a2e4d 100644 (file)
@@ -28,7 +28,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 5, 4, 241, 136,
              CBS_DROPDOWNLIST | WS_VSCROLL | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
-                 IDC_AUTOADJUST, 5, 136, 241, 10, WS_VISIBLE | WS_GROUP | WS_TABSTOP
+                 IDC_AUTODAYLIGHT, 5, 136, 241, 10, WS_VISIBLE | WS_GROUP | WS_TABSTOP
 END
 
 
index e6c5c63..6a39991 100644 (file)
@@ -12,7 +12,7 @@
 
 #define IDD_TIMEZONEPAGE       110
 #define IDC_TIMEZONELIST       111
-#define IDC_AUTOADJUST         113
+#define IDC_AUTODAYLIGHT       113
 
 #define IDS_CPLNAME            1001
 #define IDS_CPLDESCRIPTION     2001
index 74fa262..eed20cf 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: timedate.c,v 1.3 2004/11/08 10:33:08 ekohl Exp $
+/* $Id: timedate.c,v 1.4 2004/11/11 12:24:56 ekohl Exp $
  *
  * PROJECT:         ReactOS Timedate Control Panel
  * FILE:            lib/cpl/timedate/timedate.c
@@ -103,6 +103,17 @@ DateTimePageProc(HWND hwndDlg,
                 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                 break;
 
+              case PSN_SETACTIVE:
+                /* FIXME: Update the time zone name */
+                return 0;
+
+              case PSN_APPLY:
+
+                /* FIXME: Set date and time */
+
+                SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+                return TRUE;
+
               default:
                 break;
             }
@@ -348,6 +359,113 @@ ShowTimeZoneList(HWND hwnd)
 }
 
 
+static VOID
+SetLocalTimeZone(HWND hwnd)
+{
+  TIME_ZONE_INFORMATION TimeZoneInformation;
+  PTIMEZONE_ENTRY Entry;
+  DWORD dwIndex;
+  DWORD i;
+
+  dwIndex = SendMessage(hwnd,
+                       CB_GETCURSEL,
+                       0,
+                       0);
+
+  i = 0;
+  Entry = TimeZoneListHead;
+  while (i < dwIndex)
+    {
+      if (Entry == NULL)
+       return;
+
+      i++;
+      Entry = Entry->Next;
+    }
+
+  wcscpy(TimeZoneInformation.StandardName,
+        Entry->StandardName);
+  wcscpy(TimeZoneInformation.DaylightName,
+        Entry->DaylightName);
+
+  TimeZoneInformation.Bias = Entry->TimezoneInfo.Bias;
+  TimeZoneInformation.StandardBias = Entry->TimezoneInfo.StandardBias;
+  TimeZoneInformation.DaylightBias = Entry->TimezoneInfo.DaylightBias;
+
+  memcpy(&TimeZoneInformation.StandardDate,
+        &Entry->TimezoneInfo.StandardDate,
+        sizeof(SYSTEMTIME));
+  memcpy(&TimeZoneInformation.DaylightDate,
+        &Entry->TimezoneInfo.DaylightDate,
+        sizeof(SYSTEMTIME));
+
+  /* Set time zone information */
+  SetTimeZoneInformation(&TimeZoneInformation);
+}
+
+
+static VOID
+GetAutoDaylightInfo(HWND hwnd)
+{
+  HKEY hKey;
+
+  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                   L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
+                   0,
+                   KEY_SET_VALUE,
+                   &hKey))
+    return;
+
+  if (RegQueryValueExW(hKey,
+                      L"DisableAutoDaylightTimeSet",
+                      NULL,
+                      NULL,
+                      NULL,
+                      NULL))
+    {
+      SendMessage(hwnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
+    }
+  else
+    {
+      SendMessage(hwnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
+    }
+
+  RegCloseKey(hKey);
+}
+
+
+static VOID
+SetAutoDaylightInfo(HWND hwnd)
+{
+  HKEY hKey;
+  DWORD dwValue = 1;
+
+  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                   L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
+                   0,
+                   KEY_SET_VALUE,
+                   &hKey))
+    return;
+
+  if (SendMessage(hwnd, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+    {
+      RegSetValueExW(hKey,
+                    L"DisableAutoDaylightTimeSet",
+                    0,
+                    REG_DWORD,
+                    (LPBYTE)&dwValue,
+                    sizeof(DWORD));
+    }
+  else
+    {
+      RegDeleteKeyW(hKey,
+                   L"DisableAutoDaylightTimeSet");
+    }
+
+  RegCloseKey(hKey);
+}
+
+
 /* Property page dialog callback */
 INT_PTR CALLBACK
 TimeZonePageProc(HWND hwndDlg,
@@ -360,11 +478,12 @@ TimeZonePageProc(HWND hwndDlg,
     case WM_INITDIALOG:
       CreateTimeZoneList();
       ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST));
+      GetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
       break;
 
     case WM_COMMAND:
       if ((LOWORD(wParam) == IDC_TIMEZONELIST && HIWORD(wParam) == CBN_SELCHANGE) ||
-          (LOWORD(wParam) == IDC_AUTOADJUST && HIWORD(wParam) == BN_CLICKED))
+          (LOWORD(wParam) == IDC_AUTODAYLIGHT && HIWORD(wParam) == BN_CLICKED))
         {
           /* Enable the 'Apply' button */
           PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
@@ -374,6 +493,25 @@ TimeZonePageProc(HWND hwndDlg,
     case WM_DESTROY:
       DestroyTimeZoneList();
       break;
+
+    case WM_NOTIFY:
+      {
+          LPNMHDR lpnm = (LPNMHDR)lParam;
+
+          switch (lpnm->code)
+            {
+              case PSN_APPLY:
+                SetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
+                SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST));
+                SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+                return TRUE;
+
+              default:
+                break;
+            }
+
+      }
+      break;
   }
 
   return FALSE;
index 4a61b95..8931c36 100644 (file)
@@ -46,7 +46,7 @@
 #define IDC_DATEPICKER                 1015
 #define IDC_TIMEPICKER                 1016
 #define IDC_TIMEZONELIST               1017
-#define IDC_DAYLIGHTSAVINGS            1018
+#define IDC_AUTODAYLIGHT               1018
 
 #define IDD_PROCESSPAGE                        1020
 #define IDC_PROCESSPROGRESS            1021
index 777ff0c..686ed2a 100644 (file)
@@ -102,7 +102,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
-                 IDC_DAYLIGHTSAVINGS, 53, 124, 201, 10
+                 IDC_AUTODAYLIGHT, 53, 124, 201, 10
 END
 
 
index 826df9a..bddfdea 100644 (file)
@@ -104,7 +104,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "&Uhr automatisch auf Sommer-/Winterzeit umstellen",
-                 IDC_DAYLIGHTSAVINGS, 53, 124, 201, 10
+                 IDC_AUTODAYLIGHT, 53, 124, 201, 10
 END
 
 
index ef3074b..eb5f4bb 100644 (file)
@@ -104,7 +104,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
-                 IDC_DAYLIGHTSAVINGS, 53, 124, 201, 10
+                 IDC_AUTODAYLIGHT, 53, 124, 201, 10
 END
 
 
index c660afc..a47ab99 100644 (file)
@@ -105,7 +105,7 @@ BEGIN
     COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
-                 IDC_DAYLIGHTSAVINGS, 53, 124, 201, 10
+                 IDC_AUTODAYLIGHT, 53, 124, 201, 10
 END
 
 
index 8cfd7e5..d5ee644 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: wizard.c,v 1.11 2004/11/05 11:48:45 ekohl Exp $
+/* $Id: wizard.c,v 1.12 2004/11/11 12:23:43 ekohl Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS system libraries
@@ -537,7 +537,6 @@ static VOID
 CreateTimeZoneList(PSETUPDATA SetupData)
 {
   WCHAR szKeyName[256];
-//  WCHAR szValue[256];
   DWORD dwIndex;
   DWORD dwNameSize;
   DWORD dwValueSize;
@@ -693,13 +692,26 @@ CreateTimeZoneList(PSETUPDATA SetupData)
 }
 
 
-#if 0
 static VOID
 DestroyTimeZoneList(PSETUPDATA SetupData)
 {
+  PTIMEZONE_ENTRY Entry;
+
+  while (SetupData->TimeZoneListHead != NULL)
+    {
+      Entry = SetupData->TimeZoneListHead;
+
+      SetupData->TimeZoneListHead = Entry->Next;
+      if (SetupData->TimeZoneListHead != NULL)
+       {
+         SetupData->TimeZoneListHead->Prev = NULL;
+       }
+
+      HeapFree(GetProcessHeap(), 0, Entry);
+    }
 
+  SetupData->TimeZoneListTail = NULL;
 }
-#endif
 
 
 static VOID
@@ -800,6 +812,32 @@ GetLocalSystemTime(HWND hwnd, PSETUPDATA SetupData)
 }
 
 
+static VOID
+SetAutoDaylightInfo(HWND hwnd)
+{
+  HKEY hKey;
+  DWORD dwValue = 1;
+
+  if (SendMessage(hwnd, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+    {
+      if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                       L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
+                       0,
+                       KEY_SET_VALUE,
+                       &hKey))
+         return;
+
+      RegSetValueExW(hKey,
+                    L"DisableAutoDaylightTimeSet",
+                    0,
+                    REG_DWORD,
+                    (LPBYTE)&dwValue,
+                    sizeof(DWORD));
+      RegCloseKey(hKey);
+    }
+}
+
+
 INT_PTR CALLBACK
 DateTimePageDlgProc(HWND hwndDlg,
                     UINT uMsg,
@@ -822,7 +860,9 @@ DateTimePageDlgProc(HWND hwndDlg,
           CreateTimeZoneList(SetupData);
 
           ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
-                          SetupData);
+                           SetupData);
+
+          SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
         }
         break;
 
@@ -842,7 +882,8 @@ DateTimePageDlgProc(HWND hwndDlg,
                 {
                   GetLocalSystemTime(hwndDlg, SetupData);
                   SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
-                                  SetupData);
+                                   SetupData);
+                  SetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
                   SetLocalTime(&SetupData->SystemTime);
                 }
                 break;
@@ -853,6 +894,10 @@ DateTimePageDlgProc(HWND hwndDlg,
         }
         break;
 
+      case WM_DESTROY:
+        DestroyTimeZoneList(SetupData);
+        break;
+
       default:
         break;
     }