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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * PROJECT: ReactOS International Control Panel
21 * FILE: lib/cpl/intl/time.c
22 * PURPOSE: Time property page
23 * PROGRAMMER: Eric Kohl
35 * - Enumerate available time formats (use EnumTimeformatsW)
39 UpdateTimeSample(HWND hWnd
)
44 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, InBuffer
, 80);
46 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, InBuffer
, OutBuffer
, 80);
48 SendMessageW(hWnd
, WM_SETTEXT
, 0, (LPARAM
)OutBuffer
);
52 /* Property page dialog callback */
54 TimePageProc(HWND hwndDlg
,
66 /* Update the time format sample */
67 UpdateTimeSample(GetDlgItem(hwndDlg
, IDC_TIMESAMPLE
));
69 /* Get the time format (max. 80 characters) */
70 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
73 /* FIXME: add available time formats to the list */
75 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, Buffer
, 80);
76 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
80 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
85 /* Get the time separator (max. 4 characters) */
86 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
88 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_STIME
, Buffer
, 80);
89 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
93 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
98 /* Get the AM symbol (max. 9 characters) */
99 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
101 nLen
= GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S1159
, Buffer
, 80);
102 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
108 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
113 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
118 /* Get the PM symbol (max. 9 characters) */
119 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
121 nLen
= GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S2359
, Buffer
, 80);
122 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
128 SendMessageW(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
133 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
141 switch (LOWORD(wParam
))
144 case IDC_TIMESEPARATOR
:
145 case IDC_TIMEAMSYMBOL
:
146 case IDC_TIMEPMSYMBOL
:
147 if (HIWORD(wParam
) == CBN_SELCHANGE
||
148 HIWORD(wParam
) == CBN_EDITCHANGE
)
150 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
158 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
160 if (lpnm
->code
== PSN_APPLY
)
165 /* Set time format */
166 nIndex
= SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
168 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
169 CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)Buffer
);
170 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, Buffer
);
172 /* Set time separator */
173 nIndex
= SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
175 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
176 CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)Buffer
);
177 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_STIME
, Buffer
);
179 /* Set the AM symbol */
180 nIndex
= SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
182 if (nIndex
!= CB_ERR
)
184 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
185 CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)Buffer
);
186 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S1159
, Buffer
);
190 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S1159
, L
"");
193 /* Set the PM symbol */
194 nIndex
= SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
196 if (nIndex
!= CB_ERR
)
198 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
199 CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)Buffer
);
200 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S2359
, Buffer
);
204 SetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_S2359
, L
"");
207 /* Update the time format sample */
208 UpdateTimeSample(GetDlgItem(hwndDlg
, IDC_TIMESAMPLE
));