2ad1307e8e0042a19bf1fc1e3594e152b5676516
3 * Copyright (C) 2004 ReactOS Team
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.
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.
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.
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)
29 static HWND hwndTimeEnum
= NULL
;
32 TimeFormatEnumProc(PWSTR lpTimeFormatString
)
34 SendMessageW(hwndTimeEnum
,
37 (LPARAM
)lpTimeFormatString
);
43 UpdateTimeSample(HWND hWnd
, PGLOBALDATA pGlobalData
)
45 WCHAR szBuffer
[MAX_SAMPLES_STR_SIZE
];
47 GetTimeFormatW(pGlobalData
->UserLCID
, 0, NULL
,
48 pGlobalData
->szTimeFormat
, szBuffer
,
49 MAX_SAMPLES_STR_SIZE
);
50 SendDlgItemMessageW(hWnd
, IDC_TIMESAMPLE
, WM_SETTEXT
, 0, (LPARAM
)szBuffer
);
58 PGLOBALDATA pGlobalData
)
60 /* Get the time format */
61 SendDlgItemMessageW(hwndDlg
, IDC_TIMEFORMAT
,
62 CB_LIMITTEXT
, MAX_TIMEFORMAT
, 0);
64 /* Add available time formats to the list */
65 hwndTimeEnum
= GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
);
66 EnumTimeFormatsW(TimeFormatEnumProc
, pGlobalData
->UserLCID
, 0);
68 SendDlgItemMessageW(hwndDlg
, IDC_TIMEFORMAT
,
71 (LPARAM
)pGlobalData
->szTimeFormat
);
78 PGLOBALDATA pGlobalData
)
80 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
81 CB_LIMITTEXT
, MAX_TIMESEPARATOR
, 0);
83 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
86 (LPARAM
)pGlobalData
->szTimeSep
);
88 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
99 PGLOBALDATA pGlobalData
)
103 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
104 CB_LIMITTEXT
, MAX_TIMEAMSYMBOL
, 0);
106 nLen
= wcslen(pGlobalData
->szTimeAM
);
108 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
111 (LPARAM
)pGlobalData
->szTimeAM
);
114 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
120 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
131 PGLOBALDATA pGlobalData
)
135 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
136 CB_LIMITTEXT
, MAX_TIMEPMSYMBOL
, 0);
138 nLen
= wcslen(pGlobalData
->szTimeAM
);
140 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
143 (LPARAM
)pGlobalData
->szTimePM
);
146 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
151 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
162 PGLOBALDATA pGlobalData
)
164 WCHAR szTimeFormat
[MAX_TIMEFORMAT
];
165 WCHAR szTimeSep
[MAX_TIMESEPARATOR
];
166 WCHAR szTimeAM
[MAX_TIMEAMSYMBOL
];
167 WCHAR szTimePM
[MAX_TIMEPMSYMBOL
];
170 GetSelectedComboBoxText(hwndDlg
,
175 /* Check the time format */
176 if (szTimeFormat
[0] == L
'\0')
178 /* TODO: Show error message */
184 GetSelectedComboBoxText(hwndDlg
,
189 /* Check the time separator */
190 if (szTimeSep
[0] == L
'\0')
192 /* TODO: Show error message */
198 GetSelectedComboBoxText(hwndDlg
,
204 GetSelectedComboBoxText(hwndDlg
,
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
);
218 /* Property page dialog callback */
220 TimePageProc(HWND hwndDlg
,
225 PGLOBALDATA pGlobalData
;
227 pGlobalData
= (PGLOBALDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
232 pGlobalData
= (PGLOBALDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
233 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pGlobalData
);
235 /* Get the time format */
236 InitTimeFormatCB(hwndDlg
, pGlobalData
);
238 /* Get the time separator */
239 InitTimeSeparatorCB(hwndDlg
, pGlobalData
);
241 /* Get the AM symbol */
242 InitAmSymbol(hwndDlg
, pGlobalData
);
244 /* Get the PM symbol */
245 InitPmSymbol(hwndDlg
, pGlobalData
);
247 /* Update the time format sample */
248 UpdateTimeSample(hwndDlg
, pGlobalData
);
252 switch (LOWORD(wParam
))
255 case IDC_TIMESEPARATOR
:
256 case IDC_TIMEAMSYMBOL
:
257 case IDC_TIMEPMSYMBOL
:
258 if (HIWORD(wParam
) == CBN_SELCHANGE
||
259 HIWORD(wParam
) == CBN_EDITCHANGE
)
261 /* Enable the Apply button */
262 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
269 if (((LPNMHDR
)lParam
)->code
== (UINT
)PSN_APPLY
)
271 if (GetTimeSetting(hwndDlg
, pGlobalData
))
273 pGlobalData
->bUserLocaleChanged
= TRUE
;
274 UpdateTimeSample(hwndDlg
, pGlobalData
);