Defines the locale and the calendar system a control uses for names, formats and dates.
C
int SftDate_GetCulture(HWND hwndCtl, LPTSTR lpszLocaleName, int cchMax, CALID* lpCalendar); int WINAPI SftDate_GetCulture_A(HWND hwndCtl, LPSTR lpszLocaleName, int cchMax, CALID* lpCalendar); int WINAPI SftDate_GetCulture_W(HWND hwndCtl, LPWSTR lpszLocaleName, int cchMax, CALID* lpCalendar); BOOL SftDate_SetCulture(HWND hwndCtl, LPCTSTR lpszLocaleName, CALID calendar); BOOL WINAPI SftDate_SetCulture_A(HWND hwndCtl, LPCSTR lpszLocaleName, CALID calendar); BOOL WINAPI SftDate_SetCulture_W(HWND hwndCtl, LPCWSTR lpszLocaleName, CALID calendar);
C++
int CSftDate::GetCulture(LPTSTR lpszLocaleName, int cchMax, CALID* lpCalendar) const; int CSftCalendar::GetCulture(LPTSTR lpszLocaleName, int cchMax, CALID* lpCalendar) const; BOOL CSftDate::SetCulture(LPCTSTR lpszLocaleName, CALID calendar); BOOL CSftCalendar::SetCulture(LPCTSTR lpszLocaleName, CALID calendar);
hwndCtl
The window handle of the date field control (SftDate) or the month calendar control (SftCalendar).
lpszLocaleName
SetCulture: the locale name, such as "en-US", "de-DE" or "ja-JP". NULL or an empty string selects the user's locale (the Windows "Regional format" setting).
GetCulture: a pointer to the buffer that receives the locale name defined using SetCulture, or NULL.
calendar
The calendar system, a CALID value such as CAL_GREGORIAN, CAL_JAPAN or CAL_HEBREW. 0 selects the default calendar of the locale. Any other value must be one of the calendars the locale offers (GetOptionalCalendars).
cchMax
The size of the buffer in characters, including the terminating null character.
lpCalendar
A pointer to a CALID variable that receives the calendar defined using SetCulture (0 for the default calendar of the locale), or NULL.
SetCulture returns TRUE if the culture was set. FALSE is returned if the locale name is not valid, or if the locale doesn't offer the calendar or SftDate/DLL doesn't support it.
GetCulture returns the number of characters copied to the buffer, not including the terminating null character, or the length of the locale name if lpszLocaleName is NULL or cchMax is 0. The locale name is empty if the user's locale is used.
The GetCulture and SetCulture functions define and retrieve the culture of a control: the locale whose month and day names, date and time formats, first day of the week and week rule the control uses, and the calendar system in which it shows and edits dates. The culture of a date field control also applies to its dropdown calendar. By default a control uses the user's locale with its default calendar.
The supported calendar systems are Gregorian (CAL_GREGORIAN, CAL_GREGORIAN_US, CAL_GREGORIAN_ME_FRENCH, CAL_GREGORIAN_ARABIC, CAL_GREGORIAN_XLIT_ENGLISH, CAL_GREGORIAN_XLIT_FRENCH), Japanese (CAL_JAPAN), Taiwan (CAL_TAIWAN), Korean (CAL_KOREA), Thai (CAL_THAI), Hijri (CAL_HIJRI), Um Al Qura (CAL_UMALQURA), Hebrew (CAL_HEBREW) and Persian (CAL_PERSIAN). If the default calendar of a locale is not supported, the Gregorian calendar is used.
The formats of the user's locale include the user's own changes made in the Windows settings. Other locales use their standard formats.
The culture doesn't change the reading order. An application showing a right-to-left locale such as Arabic or Hebrew also calls SetRightToLeft.
The value of a control is not changed by a new culture. SYSTEMTIME values are always Gregorian dates, regardless of the calendar system of the control's culture (SetCulture).
SftDate.h maps the name without suffix to the _A (ANSI) or _W (Unicode) function, depending on whether UNICODE or _UNICODE is defined. The ANSI functions convert the text using the system code page.
hwndCal = c[FIELDS];
switch (id) {
case IDC_CULTURE: {
DWORD rtl = 0;
GetLocaleInfoEx(g_cultures[sel].lpszLocale ? g_cultures[sel].lpszLocale : LOCALE_NAME_USER_DEFAULT,
LOCALE_IREADINGLAYOUT | LOCALE_RETURN_NUMBER, (LPWSTR) &rtl, sizeof(rtl) / sizeof(WCHAR));
for (i = 0; i < CONTROLS; ++i) {
SftDate_SetCulture_W(c[i], g_cultures[sel].lpszLocale, g_cultures[sel].calendar);
SftDate_SetRightToLeft(c[i], rtl == 1);
}
ShowSelection(hwndDlg);
break;
}
case IDC_DARKMODE:
for (i = 0; i < CONTROLS; ++i) {
fChecked = IsDlgButtonChecked(id) == BST_CHECKED;
switch (id) {
case IDC_CULTURE: {
DWORD rtl = 0;
GetLocaleInfoEx(g_cultures[sel].lpszLocale ? g_cultures[sel].lpszLocale : LOCALE_NAME_USER_DEFAULT,
LOCALE_IREADINGLAYOUT | LOCALE_RETURN_NUMBER, (LPWSTR) &rtl, sizeof(rtl) / sizeof(WCHAR));
for (int i = 0; i < CONTROLS; ++i) {
Control(i).SetCulture(g_cultures[sel].lpszLocale, g_cultures[sel].calendar);
Control(i).SetRightToLeft(rtl == 1);
}
ShowSelection();
break;
}
case IDC_DARKMODE:
for (int i = 0; i < CONTROLS; ++i) {See Also C/C++ API | Categories | Notifications