Defines the format in which a date field control shows and edits its value.
C
int WINAPI SftDate_GetFormat(HWND hwndCtl); BOOL WINAPI SftDate_SetFormat(HWND hwndCtl, int format);
C++
int CSftDate::GetFormat() const; BOOL CSftDate::SetFormat(int format);
hwndCtl
The window handle of the date field control (SftDate).
format
The format. format can be one of the following values:
| SFTDATE_FORMAT_SHORTDATE | The short date format of the culture, such as 12/25/2026. This is the default. |
| SFTDATE_FORMAT_LONGDATE | The long date format of the culture, such as Friday, December 25, 2026. |
| SFTDATE_FORMAT_SHORTTIME | The short time format of the culture, such as 2:30 PM. |
| SFTDATE_FORMAT_LONGTIME | The long time format of the culture, such as 2:30:15 PM. |
| SFTDATE_FORMAT_SHORTDATETIME | The short date and short time formats. |
| SFTDATE_FORMAT_LONGDATETIME | The long date and long time formats. |
| SFTDATE_FORMAT_CUSTOM | The format defined using SetCustomFormat. |
GetFormat returns the format, one of the values listed above.
SetFormat returns TRUE if the format is valid, otherwise FALSE.
The GetFormat and SetFormat functions define and retrieve the format of a date field control. The formats other than SFTDATE_FORMAT_CUSTOM come from the culture (SetCulture).
The format defines the parts the user edits (day, month, year, hour, minute, second, AM/PM designator, era) and which dropdown opens: a calendar for a date, a time list or clock for a time, both for a date and time (SetDropDownContent). A field that shows only a date keeps the time of its value, a field that shows only a time keeps the date.
A new format closes the dropdown and ends the editing of a part. This function applies to the date field control only. For a month calendar control, GetFormat returns SFTDATE_FORMAT_SHORTDATE and SetFormat has no effect and returns FALSE.
for (i = 0; i < CONTROLS; ++i) {
SftDate_SetDarkMode(c[i], SFTDATE_DARKMODE_AUTO);
SftDate_SetHighContrastMode(c[i], SFTDATE_HIGHCONTRAST_AUTO);
SftDate_SetImageScaling(c[i], SFTDATE_IMAGESCALING_STRETCH);
SftDate_SetValue(c[i], &now);
}
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_LONGDATE), SFTDATE_FORMAT_LONGDATE);
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_TIMELIST), SFTDATE_FORMAT_SHORTTIME);
SftDate_SetTimeInterval(GetDlgItem(hwndDlg, IDC_TIMELIST), 15);
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_TIMECLOCK), SFTDATE_FORMAT_SHORTTIME);
SftDate_SetTimeDropDownStyle(GetDlgItem(hwndDlg, IDC_TIMECLOCK), SFTDATE_TIMESTYLE_CLOCK);
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_DATETIME), SFTDATE_FORMAT_SHORTDATETIME);
for (int i = 0; i < CONTROLS; ++i) {
Control(i).SetDarkMode(SFTDATE_DARKMODE_AUTO);
Control(i).SetHighContrastMode(SFTDATE_HIGHCONTRAST_AUTO);
Control(i).SetImageScaling(SFTDATE_IMAGESCALING_STRETCH);
Control(i).SetValue(&now);
}
m_Fields[1].SetFormat(SFTDATE_FORMAT_LONGDATE);
m_Fields[2].SetFormat(SFTDATE_FORMAT_SHORTTIME);
m_Fields[2].SetTimeInterval(15);
m_Fields[3].SetFormat(SFTDATE_FORMAT_SHORTTIME);
m_Fields[3].SetTimeDropDownStyle(SFTDATE_TIMESTYLE_CLOCK);
m_Fields[4].SetFormat(SFTDATE_FORMAT_SHORTDATETIME);See Also C/C++ API | Categories | Notifications