511400d616e96a86557fcb8654d6ce6eed61d6d5
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 * PROGRAMMER: Eric Kohl
28 static HWND hwndEnum
= NULL
;
31 TimeFormatEnumProc(PWSTR lpTimeFormatString
)
33 SendMessageW(hwndEnum
,
36 (LPARAM
)lpTimeFormatString
);
42 UpdateTimeSample(HWND hWnd
, PGLOBALDATA pGlobalData
)
44 WCHAR szBuffer
[MAX_SAMPLES_STR_SIZE
];
46 GetTimeFormatW(pGlobalData
->UserLCID
, 0, NULL
,
47 pGlobalData
->szTimeFormat
, szBuffer
,
48 MAX_SAMPLES_STR_SIZE
);
49 SendDlgItemMessageW(hWnd
, IDC_TIMESAMPLE
, WM_SETTEXT
, 0, (LPARAM
)szBuffer
);
54 GetSelectedComboEntry(HWND hwndDlg
, DWORD dwIdc
, WCHAR
*Buffer
, UINT uSize
)
61 /* Get handle to time format control */
62 hChildWnd
= GetDlgItem(hwndDlg
, dwIdc
);
64 /* Get index to selected time format */
65 nIndex
= SendMessageW(hChildWnd
, CB_GETCURSEL
, 0, 0);
68 /* No selection? Get content of the edit control */
69 SendMessageW(hChildWnd
, WM_GETTEXT
, uSize
, (LPARAM
)Buffer
);
73 /* Get requested size, including the null terminator;
74 * it shouldn't be required because the previous CB_LIMITTEXT,
75 * but it would be better to check it anyways */
76 uReqSize
= SendMessageW(hChildWnd
, CB_GETLBTEXTLEN
, (WPARAM
)nIndex
, 0) + 1;
78 /* Allocate enough space to be more safe */
79 tmp
= (PWSTR
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, uReqSize
* sizeof(WCHAR
));
82 /* Get selected time format text */
83 SendMessageW(hChildWnd
, CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)tmp
);
85 /* Finally, copy the result into the output */
86 wcsncpy(Buffer
, tmp
, uSize
);
88 HeapFree(GetProcessHeap(), 0, tmp
);
98 PGLOBALDATA pGlobalData
)
100 /* Get the time format */
101 SendDlgItemMessageW(hwndDlg
, IDC_TIMEFORMAT
,
102 CB_LIMITTEXT
, MAX_TIMEFORMAT
, 0);
104 /* Add available time formats to the list */
105 hwndEnum
= GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
);
106 EnumTimeFormatsW(TimeFormatEnumProc
, pGlobalData
->UserLCID
, 0);
108 SendDlgItemMessageW(hwndDlg
, IDC_TIMEFORMAT
,
111 (LPARAM
)pGlobalData
->szTimeFormat
);
118 PGLOBALDATA pGlobalData
)
120 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
121 CB_LIMITTEXT
, MAX_TIMESEPARATOR
, 0);
123 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
126 (LPARAM
)pGlobalData
->szTimeSep
);
128 SendDlgItemMessageW(hwndDlg
, IDC_TIMESEPARATOR
,
139 PGLOBALDATA pGlobalData
)
143 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
144 CB_LIMITTEXT
, MAX_TIMEAMSYMBOL
, 0);
146 nLen
= wcslen(pGlobalData
->szTimeAM
);
148 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
151 (LPARAM
)pGlobalData
->szTimeAM
);
154 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
160 SendDlgItemMessageW(hwndDlg
, IDC_TIMEAMSYMBOL
,
171 PGLOBALDATA pGlobalData
)
175 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
176 CB_LIMITTEXT
, MAX_TIMEPMSYMBOL
, 0);
178 nLen
= wcslen(pGlobalData
->szTimeAM
);
180 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
183 (LPARAM
)pGlobalData
->szTimePM
);
186 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
191 SendDlgItemMessageW(hwndDlg
, IDC_TIMEPMSYMBOL
,
198 /* Property page dialog callback */
200 TimePageProc(HWND hwndDlg
,
205 PGLOBALDATA pGlobalData
;
207 pGlobalData
= (PGLOBALDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
212 pGlobalData
= (PGLOBALDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
213 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pGlobalData
);
215 /* Get the time format */
216 InitTimeFormatCB(hwndDlg
, pGlobalData
);
218 /* Get the time separator */
219 InitTimeSeparatorCB(hwndDlg
, pGlobalData
);
221 /* Get the AM symbol */
222 InitAmSymbol(hwndDlg
, pGlobalData
);
224 /* Get the PM symbol */
225 InitPmSymbol(hwndDlg
, pGlobalData
);
227 /* Update the time format sample */
228 UpdateTimeSample(hwndDlg
, pGlobalData
);
232 switch (LOWORD(wParam
))
235 case IDC_TIMESEPARATOR
:
236 case IDC_TIMEAMSYMBOL
:
237 case IDC_TIMEPMSYMBOL
:
238 if (HIWORD(wParam
) == CBN_SELCHANGE
||
239 HIWORD(wParam
) == CBN_EDITCHANGE
)
241 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
248 if (((LPNMHDR
)lParam
)->code
== (UINT
)PSN_APPLY
)
250 /* Get selected/typed time format text */
251 GetSelectedComboEntry(hwndDlg
, IDC_TIMEFORMAT
,
252 pGlobalData
->szTimeFormat
,
255 /* Get selected/typed time separator text */
256 GetSelectedComboEntry(hwndDlg
, IDC_TIMESEPARATOR
,
257 pGlobalData
->szTimeSep
,
260 /* Get selected/typed AM symbol text */
261 GetSelectedComboEntry(hwndDlg
, IDC_TIMEAMSYMBOL
,
262 pGlobalData
->szTimeAM
,
265 /* Get selected/typed PM symbol text */
266 GetSelectedComboEntry(hwndDlg
, IDC_TIMEPMSYMBOL
,
267 pGlobalData
->szTimePM
,
270 pGlobalData
->bUserLocaleChanged
= TRUE
;
272 /* Update the time format sample */
273 UpdateTimeSample(hwndDlg
, pGlobalData
);