Fill the time zone list.

svn path=/trunk/; revision=11577
This commit is contained in:
Eric Kohl 2004-11-07 16:03:51 +00:00
parent 5a1530f454
commit 3c3bf1e647
5 changed files with 325 additions and 25 deletions

View file

@ -6,9 +6,18 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Datum && Uhrzeit"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
GROUPBOX "&Datum", -1, 4, 2, 122, 125
GROUPBOX "&Zeit", -1, 132, 2, 113, 125
LTEXT "Aktuelle Zeitzone: %s", IDC_TIMEZONE, 4, 136, 241, 8
GROUPBOX "&Datum", -1, 4, 2, 122, 125
CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
DTS_SHORTDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
11, 17, 108, 12
CONTROL "", IDC_MONTHCALENDAR, "SysMonthCal32",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
11, 37, 108, 80
GROUPBOX "&Zeit", -1, 132, 2, 113, 125
CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
144, 17, 90, 12
LTEXT "Aktuelle Zeitzone: %s", IDC_TIMEZONE, 4, 136, 241, 8
END
@ -17,15 +26,15 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Zeitzone"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
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
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
END
STRINGTABLE
BEGIN
IDS_CPLNAME "Datum/Zeit"
IDS_CPLDESCRIPTION "Ändert die Uhrzeit, Datum und Zeitzone."
IDS_CPLNAME "Datum/Zeit"
IDS_CPLDESCRIPTION "Ändert die Uhrzeit, Datum und Zeitzone."
END

View file

@ -5,9 +5,18 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Date && Time"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
GROUPBOX "&Date", -1, 4, 2, 122, 125
GROUPBOX "&Time", -1, 132, 2, 113, 125
LTEXT "Current time zone: %s", IDC_TIMEZONE, 4, 136, 241, 8
GROUPBOX "&Date", -1, 4, 2, 122, 125
CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
DTS_SHORTDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
11, 17, 108, 12
CONTROL "", IDC_MONTHCALENDAR, "SysMonthCal32",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
11, 37, 108, 80
GROUPBOX "&Time", -1, 132, 2, 113, 125
CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
144, 17, 90, 12
LTEXT "Current time zone: %s", IDC_TIMEZONE, 4, 136, 241, 8
END
@ -16,15 +25,15 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Time Zone"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
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
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
END
STRINGTABLE
BEGIN
IDS_CPLNAME "Date/Time"
IDS_CPLDESCRIPTION "Changes date, time and time zone information."
IDS_CPLNAME "Date/Time"
IDS_CPLDESCRIPTION "Changes date, time and time zone information."
END

View file

@ -5,7 +5,10 @@
#define IDC_CPLICON 1
#define IDD_DATETIMEPAGE 100
#define IDC_DATEPICKER 101
#define IDC_MONTHCALENDAR 102
#define IDC_TIMEZONE 106
#define IDC_TIMEPICKER 107
#define IDD_TIMEZONEPAGE 110
#define IDC_TIMEZONELIST 111

View 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.1 2004/10/30 19:15:31 ekohl Exp $
/* $Id: timedate.c,v 1.2 2004/11/07 16:03:51 ekohl Exp $
*
* PROJECT: ReactOS Timedate Control Panel
* FILE: lib/cpl/timedate/timedate.c
@ -32,6 +32,27 @@
#include "timedate.h"
typedef struct _TZ_INFO
{
LONG Bias;
LONG StandardBias;
LONG DaylightBias;
SYSTEMTIME StandardDate;
SYSTEMTIME DaylightDate;
} TZ_INFO, *PTZ_INFO;
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;
#define NUM_APPLETS (1)
LONG APIENTRY
@ -40,6 +61,9 @@ Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
HINSTANCE hApplet = 0;
PTIMEZONE_ENTRY TimeZoneListHead = NULL;
PTIMEZONE_ENTRY TimeZoneListTail = NULL;
/* Applets */
APPLET Applets[NUM_APPLETS] =
@ -58,6 +82,13 @@ DateTimePageProc(HWND hwndDlg,
switch (uMsg)
{
case WM_INITDIALOG:
{
TIME_ZONE_INFORMATION TimeZoneInfo;
GetTimeZoneInformation(&TimeZoneInfo);
SendDlgItemMessageW(hwndDlg, IDC_TIMEZONE, WM_SETTEXT, 0, (LPARAM)TimeZoneInfo.StandardName);
}
break;
}
@ -65,6 +96,229 @@ DateTimePageProc(HWND hwndDlg,
}
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
CreateTimeZoneList(VOID)
{
WCHAR szKeyName[256];
DWORD dwIndex;
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(hZoneKey);
break;
}
dwValueSize = 64 * sizeof(WCHAR);
if (RegQueryValueExW(hZoneKey,
L"Display",
NULL,
NULL,
(LPBYTE)&Entry->Description,
&dwValueSize))
{
RegCloseKey(hZoneKey);
break;
}
dwValueSize = 32 * sizeof(WCHAR);
if (RegQueryValueExW(hZoneKey,
L"Std",
NULL,
NULL,
(LPBYTE)&Entry->StandardName,
&dwValueSize))
{
RegCloseKey(hZoneKey);
break;
}
dwValueSize = 32 * sizeof(WCHAR);
if (RegQueryValueExW(hZoneKey,
L"Dlt",
NULL,
NULL,
(LPBYTE)&Entry->DaylightName,
&dwValueSize))
{
RegCloseKey(hZoneKey);
break;
}
dwValueSize = sizeof(DWORD);
if (RegQueryValueExW(hZoneKey,
L"Index",
NULL,
NULL,
(LPBYTE)&Entry->Index,
&dwValueSize))
{
RegCloseKey(hZoneKey);
break;
}
dwValueSize = sizeof(TZ_INFO);
if (RegQueryValueExW(hZoneKey,
L"TZI",
NULL,
NULL,
(LPBYTE)&Entry->TimezoneInfo,
&dwValueSize))
{
RegCloseKey(hZoneKey);
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);
}
static VOID
DestroyTimeZoneList(VOID)
{
PTIMEZONE_ENTRY Entry;
while (TimeZoneListHead != NULL)
{
Entry = TimeZoneListHead;
TimeZoneListHead = Entry->Next;
if (TimeZoneListHead != NULL)
{
TimeZoneListHead->Prev = NULL;
}
HeapFree(GetProcessHeap(), 0, Entry);
}
TimeZoneListTail = NULL;
}
static VOID
ShowTimeZoneList(HWND hwnd)
{
PTIMEZONE_ENTRY Entry;
Entry = TimeZoneListHead;
while (Entry != NULL)
{
SendMessageW(hwnd,
CB_ADDSTRING,
0,
(LPARAM)Entry->Description);
Entry = Entry->Next;
}
SendMessageW(hwnd,
CB_SETCURSEL,
(WPARAM)0, // index
0);
}
/* Property page dialog callback */
INT_PTR CALLBACK
TimeZonePageProc(HWND hwndDlg,
@ -75,6 +329,21 @@ TimeZonePageProc(HWND hwndDlg,
switch (uMsg)
{
case WM_INITDIALOG:
CreateTimeZoneList();
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST));
break;
case WM_COMMAND:
if ((LOWORD(wParam) == IDC_TIMEZONELIST && HIWORD(wParam) == CBN_SELCHANGE) ||
(LOWORD(wParam) == IDC_AUTOADJUST && HIWORD(wParam) == BN_CLICKED))
{
/* Enable the 'Apply' button */
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
break;
case WM_DESTROY:
DestroyTimeZoneList();
break;
}
@ -166,8 +435,15 @@ DllMain(HINSTANCE hinstDLL,
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
{
INITCOMMONCONTROLSEX InitControls;
InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitControls.dwICC = ICC_DATE_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS;
InitCommonControlsEx(&InitControls);
hApplet = hinstDLL;
}
break;
}

View file

@ -1,8 +1,11 @@
#include <windows.h>
#include <commctrl.h>
#include <defines.h>
#include "resource.h"
#include "windows.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
#include "resource.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS time/date Control Panel\0"
@ -10,8 +13,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
#define REACTOS_STR_ORIGINAL_FILENAME "timedate.cpl\0"
#include <reactos/version.rc>
IDC_CPLICON ICON "resources/applet.ico"
IDC_CPLICON ICON "resources/applet.ico"
#include "En.rc"