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(LPTSTR lpTimeFormatString
)
36 (LPARAM
)lpTimeFormatString
);
42 UpdateTimeSample(HWND hWnd
, LCID lcid
)
46 GetTimeFormat(lcid
, 0, NULL
, NULL
, szBuffer
, 80);
47 SendMessage(hWnd
, WM_SETTEXT
, 0, (LPARAM
)szBuffer
);
52 GetSelectedComboEntry(HWND hwndDlg
, DWORD dwIdc
, TCHAR
*Buffer
, UINT uSize
)
57 /* Get handle to time format control */
58 hChildWnd
= GetDlgItem(hwndDlg
, dwIdc
);
59 /* Get index to selected time format */
60 nIndex
= SendMessage(hChildWnd
, CB_GETCURSEL
, 0, 0);
62 /* No selection? Get content of the edit control */
63 SendMessage(hChildWnd
, WM_GETTEXT
, uSize
, (LPARAM
)Buffer
);
68 /* Get requested size, including the null terminator;
69 * it shouldn't be required because the previous CB_LIMITTEXT,
70 * but it would be better to check it anyways */
71 uReqSize
= SendMessage(hChildWnd
, CB_GETLBTEXTLEN
, (WPARAM
)nIndex
, 0) + 1;
72 /* Allocate enough space to be more safe */
73 tmp
= (LPTSTR
)_alloca(uReqSize
*sizeof(TCHAR
));
74 /* Get selected time format text */
75 SendMessage(hChildWnd
, CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)tmp
);
76 /* Finally, copy the result into the output */
77 _tcsncpy(Buffer
, tmp
, uSize
);
81 /* Property page dialog callback */
83 TimePageProc(HWND hwndDlg
,
88 PGLOBALDATA pGlobalData
;
90 pGlobalData
= (PGLOBALDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
99 pGlobalData
= (PGLOBALDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
100 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pGlobalData
);
102 /* Update the time format sample */
103 UpdateTimeSample(GetDlgItem(hwndDlg
, IDC_TIMESAMPLE
), pGlobalData
->lcid
);
105 /* Get the time format */
106 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
107 CB_LIMITTEXT
, MAX_TIMEFORMAT
, 0);
109 /* Add available time formats to the list */
110 hwndEnum
= GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
);
111 EnumTimeFormats(TimeFormatEnumProc
, pGlobalData
->lcid
, 0);
113 GetLocaleInfo(pGlobalData
->lcid
, LOCALE_STIMEFORMAT
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
114 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEFORMAT
),
119 /* Get the time separator */
120 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
121 CB_LIMITTEXT
, MAX_TIMESEPARATOR
, 0);
122 GetLocaleInfo(pGlobalData
->lcid
, LOCALE_STIME
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
123 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
127 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMESEPARATOR
),
132 /* Get the AM symbol */
133 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
134 CB_LIMITTEXT
, MAX_TIMEAMSYMBOL
, 0);
135 nLen
= GetLocaleInfo(pGlobalData
->lcid
, LOCALE_S1159
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
136 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
142 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
147 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEAMSYMBOL
),
152 /* Get the PM symbol */
153 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
154 CB_LIMITTEXT
, MAX_TIMEPMSYMBOL
, 0);
155 nLen
= GetLocaleInfo(pGlobalData
->lcid
, LOCALE_S2359
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
156 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
162 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
167 SendMessage(GetDlgItem(hwndDlg
, IDC_TIMEPMSYMBOL
),
175 switch (LOWORD(wParam
))
178 case IDC_TIMESEPARATOR
:
179 case IDC_TIMEAMSYMBOL
:
180 case IDC_TIMEPMSYMBOL
:
181 if (HIWORD(wParam
) == CBN_SELCHANGE
||
182 HIWORD(wParam
) == CBN_EDITCHANGE
)
184 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
192 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
194 if (lpnm
->code
== (UINT
)PSN_APPLY
)
198 /* Get selected/typed time format text */
199 GetSelectedComboEntry(hwndDlg
, IDC_TIMEFORMAT
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
201 /* Set time format */
202 SetLocaleInfo(pGlobalData
->lcid
, LOCALE_STIMEFORMAT
, Buffer
);
204 /* Get selected/typed time separator text */
205 GetSelectedComboEntry(hwndDlg
, IDC_TIMESEPARATOR
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
207 /* Set time separator */
208 SetLocaleInfo(pGlobalData
->lcid
, LOCALE_STIME
, Buffer
);
210 /* Get selected/typed AM symbol text */
211 GetSelectedComboEntry(hwndDlg
, IDC_TIMEAMSYMBOL
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
213 /* Set the AM symbol */
214 SetLocaleInfo(pGlobalData
->lcid
, LOCALE_S1159
, Buffer
);
216 /* Get selected/typed PM symbol text */
217 GetSelectedComboEntry(hwndDlg
, IDC_TIMEPMSYMBOL
, Buffer
, sizeof(Buffer
)/sizeof(TCHAR
));
219 /* Set the PM symbol */
220 SetLocaleInfo(pGlobalData
->lcid
, LOCALE_S2359
, Buffer
);
222 /* Update the time format sample */
223 UpdateTimeSample(GetDlgItem(hwndDlg
, IDC_TIMESAMPLE
), pGlobalData
->lcid
);