SftDate_SetEditStyle defines how the user enters the value of a field: one part at a time (SFTDATE_EDIT_SEGMENTS, the default) or by typing the whole value as text (SFTDATE_EDIT_FREEFORM).

With SFTDATE_EDIT_SEGMENTS, each part of the value (day, month, year, hours, minutes, seconds, fractions of a second, AM/PM) is edited separately. The part being edited is highlighted in the SFTDATE_COLOR_SEGMENTBACK and SFTDATE_COLOR_SEGMENTFORE colors while the field has the input focus.
When a change creates a date that does not exist, such as February 30, the day is reduced to the last day of the month.
While some parts of a value are empty, the value is incomplete. It is completed with the missing parts from the earlier value, or from the current date and time when the field was empty, when the user presses Enter, tabs past the last part, opens the dropdown or leaves the field.
Each change the user makes is checked before it is accepted (see Validation).
With SFTDATE_EDIT_FREEFORM, the user types the value as text, in a text box the field shows in place of its parts. The text is parsed when the user presses Enter, leaves the field or opens the dropdown. A text that cannot be parsed is refused with a beep and the previous value is shown again; an empty text empties the field when empty values are allowed or a check box is shown. Escape restores the text of the current value. The Up and Down keys and the up and down buttons change the value by one day, or by one minute in a field showing only a time.
A text is parsed in the following order:
Parts the format does not show are kept from the current value; a time typed in a date and time field keeps the date. In range mode, the first and the last date are separated by the text defined by SftDate_SetRangeSeparator, and each of them is parsed on its own.
Text set with WM_SETTEXT and text pasted into a field with segment editing are parsed the same way.
The NM_SFTDATE_TEXTPARSING notification is sent before a text typed in a free-form field, pasted into a field or set with WM_SETTEXT is parsed. The SFTDATE_NMTEXTPARSING structure holds the text (lpszText) and the current value (current, when fHasCurrent is TRUE). The application sets fHandled to TRUE to indicate that it parsed the text, and fHasValue and value to the value the text represents; fHandled with fHasValue FALSE refuses the text. This example accepts "+7" or "-3" as a number of days from the current value:
case WM_NOTIFY: {
LPNMHDR lpnmhdr = (LPNMHDR) lParam;
if (lpnmhdr->idFrom == IDC_DUEDATE && lpnmhdr->code == NM_SFTDATE_TEXTPARSING) {
LPSFTDATE_NMTEXTPARSING lpParse = (LPSFTDATE_NMTEXTPARSING) lParam;
LPCTSTR p = lpParse->lpszText;
if ((p[0] == TEXT('+') || p[0] == TEXT('-')) && _istdigit(p[1]) && lpParse->fHasCurrent) {
FILETIME ft;
ULARGE_INTEGER t;
int days = _ttoi(p);
SystemTimeToFileTime(&lpParse->current, &ft);
t.LowPart = ft.dwLowDateTime;
t.HighPart = ft.dwHighDateTime;
t.QuadPart += (LONGLONG) days * 24 * 60 * 60 * 10000000;
ft.dwLowDateTime = t.LowPart;
ft.dwHighDateTime = t.HighPart;
lpParse->fHasValue = FileTimeToSystemTime(&ft, &lpParse->value);
lpParse->fHandled = TRUE;
}
return TRUE;
}
break;
}The value is then checked like any value the user enters (see Validation).