ReactOS 0.4.15-dev-7924-g5949c20
time.c
Go to the documentation of this file.
1/*
2 * ReactOS
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19/*
20 * PROJECT: ReactOS International Control Panel
21 * FILE: dll/cpl/intl/time.c
22 * PURPOSE: Time property page
23 * PROGRAMMERS: Eric Kohl
24 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
25 */
26
27#include "intl.h"
28
30
31static BOOL CALLBACK
32TimeFormatEnumProc(PWSTR lpTimeFormatString)
33{
36 0,
37 (LPARAM)lpTimeFormatString);
38
39 return TRUE;
40}
41
42static VOID
44{
46
47 GetTimeFormatW(pGlobalData->UserLCID, 0, NULL,
48 pGlobalData->szTimeFormat, szBuffer,
51}
52
53
54static
55VOID
57 HWND hwndDlg,
58 PGLOBALDATA pGlobalData)
59{
60 /* Get the time format */
63
64 /* Add available time formats to the list */
67
70 -1,
71 (LPARAM)pGlobalData->szTimeFormat);
72}
73
74static
75VOID
77 HWND hwndDlg,
78 PGLOBALDATA pGlobalData)
79{
82
85 0,
86 (LPARAM)pGlobalData->szTimeSep);
87
90 0, /* Index */
91 0);
92}
93
94
95static
96VOID
98 HWND hwndDlg,
99 PGLOBALDATA pGlobalData)
100{
101 int nLen;
102
105
106 nLen = wcslen(pGlobalData->szTimeAM);
107
110 0,
111 (LPARAM)pGlobalData->szTimeAM);
112 if (nLen != 0)
113 {
116 0,
117 (LPARAM)L"");
118 }
119
122 0, /* Index */
123 0);
124}
125
126
127static
128VOID
130 HWND hwndDlg,
131 PGLOBALDATA pGlobalData)
132{
133 int nLen;
134
137
138 nLen = wcslen(pGlobalData->szTimeAM);
139
142 0,
143 (LPARAM)pGlobalData->szTimePM);
144 if (nLen != 0)
145 {
148 0,
149 (LPARAM)L"");
150 }
153 0, /* Index */
154 0);
155}
156
157
158static
159BOOL
161 HWND hwndDlg,
162 PGLOBALDATA pGlobalData)
163{
164 WCHAR szTimeFormat[MAX_TIMEFORMAT];
165 WCHAR szTimeSep[MAX_TIMESEPARATOR];
166 WCHAR szTimeAM[MAX_TIMEAMSYMBOL];
167 WCHAR szTimePM[MAX_TIMEPMSYMBOL];
168
169 /* Time format */
172 szTimeFormat,
174
175 /* Check the time format */
176 if (szTimeFormat[0] == L'\0')
177 {
178 /* TODO: Show error message */
179
180 return FALSE;
181 }
182
183 /* Time separator */
186 szTimeSep,
188
189 /* Check the time separator */
190 if (szTimeSep[0] == L'\0')
191 {
192 /* TODO: Show error message */
193
194 return FALSE;
195 }
196
197 /* AM symbol */
200 szTimeAM,
202
203 /* PM symbol */
206 szTimePM,
208
209 /* Store settings in global data */
210 wcscpy(pGlobalData->szTimeFormat, szTimeFormat);
211 wcscpy(pGlobalData->szTimeSep, szTimeSep);
212 wcscpy(pGlobalData->szTimeAM, szTimeAM);
213 wcscpy(pGlobalData->szTimePM, szTimePM);
214
215 return TRUE;
216}
217
218/* Property page dialog callback */
221 UINT uMsg,
224{
225 PGLOBALDATA pGlobalData;
226
227 pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
228
229 switch (uMsg)
230 {
231 case WM_INITDIALOG:
232 pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
233 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
234
235 /* Get the time format */
236 InitTimeFormatCB(hwndDlg, pGlobalData);
237
238 /* Get the time separator */
239 InitTimeSeparatorCB(hwndDlg, pGlobalData);
240
241 /* Get the AM symbol */
242 InitAmSymbol(hwndDlg, pGlobalData);
243
244 /* Get the PM symbol */
245 InitPmSymbol(hwndDlg, pGlobalData);
246
247 /* Update the time format sample */
248 UpdateTimeSample(hwndDlg, pGlobalData);
249 break;
250
251 case WM_COMMAND:
252 switch (LOWORD(wParam))
253 {
254 case IDC_TIMEFORMAT:
256 case IDC_TIMEAMSYMBOL:
257 case IDC_TIMEPMSYMBOL:
258 if (HIWORD(wParam) == CBN_SELCHANGE ||
260 {
261 /* Enable the Apply button */
262 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
263 }
264 break;
265 }
266 break;
267
268 case WM_NOTIFY:
269 if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
270 {
271 if (GetTimeSetting(hwndDlg, pGlobalData))
272 {
273 pGlobalData->bUserLocaleChanged = TRUE;
274 UpdateTimeSample(hwndDlg, pGlobalData);
275 }
276 }
277 break;
278 }
279
280 return FALSE;
281}
282
283/* EOF */
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_TIMEPMSYMBOL
Definition: resource.h:49
#define IDC_TIMEAMSYMBOL
Definition: resource.h:48
#define IDC_TIMESEPARATOR
Definition: resource.h:47
#define IDC_TIMEFORMAT
Definition: resource.h:46
#define IDC_TIMESAMPLE
Definition: resource.h:45
static BOOL GetTimeSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: time.c:160
static VOID InitAmSymbol(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: time.c:97
static BOOL CALLBACK TimeFormatEnumProc(PWSTR lpTimeFormatString)
Definition: time.c:32
INT_PTR CALLBACK TimePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: time.c:220
static VOID InitTimeFormatCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: time.c:56
static VOID InitTimeSeparatorCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: time.c:76
static VOID UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData)
Definition: time.c:43
static HWND hwndTimeEnum
Definition: time.c:29
static VOID InitPmSymbol(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: time.c:129
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MAX_TIMESEPARATOR
Definition: intl.h:39
VOID GetSelectedComboBoxText(HWND hwndDlg, INT nIdDlgItem, PWSTR Buffer, UINT uSize)
Definition: misc.c:176
struct _GLOBALDATA * PGLOBALDATA
#define MAX_TIMEPMSYMBOL
Definition: intl.h:41
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
#define MAX_TIMEAMSYMBOL
Definition: intl.h:40
#define MAX_TIMEFORMAT
Definition: intl.h:38
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
BOOL WINAPI EnumTimeFormatsW(TIMEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
Definition: lcformat.c:2157
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define WM_NOTIFY
Definition: richedit.h:61
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
WCHAR szTimePM[MAX_TIMEPMSYMBOL]
Definition: intl.h:93
LCID UserLCID
Definition: intl.h:113
WCHAR szTimeFormat[MAX_TIMEFORMAT]
Definition: intl.h:90
WCHAR szTimeAM[MAX_TIMEAMSYMBOL]
Definition: intl.h:92
WCHAR szTimeSep[MAX_TIMESEPARATOR]
Definition: intl.h:91
Definition: inflate.c:139
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_SELECTSTRING
Definition: winuser.h:1960
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_SETCURSEL
Definition: winuser.h:1961
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CBN_SELCHANGE
Definition: winuser.h:1979
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1617
#define CB_ADDSTRING
Definition: winuser.h:1936
HWND WINAPI GetParent(_In_ HWND)
#define CB_LIMITTEXT
Definition: winuser.h:1958
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CBN_EDITCHANGE
Definition: winuser.h:1975
__wchar_t WCHAR
Definition: xmlstorage.h:180