Values the user enters in a field are checked in three steps:
Every change the user makes is checked this way: a typed or changed part, a value chosen in the dropdown, a text typed with free-form editing or pasted, and a field emptied with the Delete key or the Clear button. Values set by the application, with SftDate_SetValue, SftDate_SetRange or WM_SETTEXT, are not checked, and clearing or checking the check box only hides or shows the value, so neither sends NM_SFTDATE_VALUEVALIDATING. A calendar has no validation; its selection is limited by its minimum and maximum dates and by the days that cannot be selected (see below).
The SFTDATE_NMVALIDATING structure holds the value the user entered in newValue, with fHasValue FALSE when the user empties the field; in range mode, newRangeEnd and fHasRangeEnd hold the last date of the range. Setting fCancel to TRUE refuses the value, and the field shows the previous value again. Changing newValue or newRangeEnd accepts a different value instead; it is moved into the limits like a value the user entered.
This example refuses Saturdays and Sundays:
case WM_NOTIFY: {
LPNMHDR lpnmhdr = (LPNMHDR) lParam;
if (lpnmhdr->idFrom == IDC_APPOINTMENT && lpnmhdr->code == NM_SFTDATE_VALUEVALIDATING) {
LPSFTDATE_NMVALIDATING lpVal = (LPSFTDATE_NMVALIDATING) lParam;
if (lpVal->fHasValue && (lpVal->newValue.wDayOfWeek == 0 || lpVal->newValue.wDayOfWeek == 6))
lpVal->fCancel = TRUE;
return TRUE;
}
break;
}In a calendar, including the dropdown calendar of a field, days can be made unavailable: SftDate_SetDisabledDaysOfWeek disables days of the week, a special date with fEnabled set to FALSE disables a day (see Special Dates), and the NM_SFTDATE_DAYFORMATTING notification can disable any day (see Day Formatting). Disabled days are shown in the SFTDATE_COLOR_DISABLEDFORE color and cannot be selected; days outside the minimum and maximum dates are disabled as well.
SftDate_SetDisabledDaysOfWeek(hwndField, SFTDATE_DAYS_WEEKEND); /* Saturday and Sunday */

These settings apply to the calendar only. A field's NM_SFTDATE_VALUEVALIDATING notification refuses such days when the user types them.
A text the user types in a free-form field or pastes into a field can be parsed by the application in the NM_SFTDATE_TEXTPARSING notification before the field parses it (see Editing).