From: Eric Kohl Date: Sun, 7 Nov 2004 16:03:51 +0000 (+0000) Subject: Fill the time zone list. X-Git-Tag: backups/win32k_user_rewrite@16797~1^2~131 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=3c3bf1e6479b6e824e0ee003e78160c01fb509f0 Fill the time zone list. svn path=/trunk/; revision=11577 --- diff --git a/reactos/lib/cpl/timedate/De.rc b/reactos/lib/cpl/timedate/De.rc index 00226bfeff6..92fe37c9c26 100644 --- a/reactos/lib/cpl/timedate/De.rc +++ b/reactos/lib/cpl/timedate/De.rc @@ -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 diff --git a/reactos/lib/cpl/timedate/En.rc b/reactos/lib/cpl/timedate/En.rc index 83728e15043..8ae7000827d 100644 --- a/reactos/lib/cpl/timedate/En.rc +++ b/reactos/lib/cpl/timedate/En.rc @@ -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 diff --git a/reactos/lib/cpl/timedate/resource.h b/reactos/lib/cpl/timedate/resource.h index c26fb1c11e8..e6c5c63f733 100644 --- a/reactos/lib/cpl/timedate/resource.h +++ b/reactos/lib/cpl/timedate/resource.h @@ -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 diff --git a/reactos/lib/cpl/timedate/timedate.c b/reactos/lib/cpl/timedate/timedate.c index 888f7950982..3c71f8551bb 100644 --- a/reactos/lib/cpl/timedate/timedate.c +++ b/reactos/lib/cpl/timedate/timedate.c @@ -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; } diff --git a/reactos/lib/cpl/timedate/timedate.rc b/reactos/lib/cpl/timedate/timedate.rc index e0a6687370a..1f0aa9c85ce 100644 --- a/reactos/lib/cpl/timedate/timedate.rc +++ b/reactos/lib/cpl/timedate/timedate.rc @@ -1,8 +1,11 @@ +#include +#include #include + #include "resource.h" -#include "windows.h" -LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT + +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 -IDC_CPLICON ICON "resources/applet.ico" +IDC_CPLICON ICON "resources/applet.ico" #include "En.rc"