HeaderPane
Main
Hide
Share Link
Print

SFTDATE_NMVALIDATING Structure

The SFTDATE_NMVALIDATING structure is sent with the NM_SFTDATE_VALUEVALIDATING notification before a change the user made to the value of a date field control is applied.

typedef struct tagSftDateNMValidating {
    NMHDR hdr;
    BOOL fHasValue;         // in/out
    SYSTEMTIME newValue;    // in/out
    BOOL fHasRangeEnd;      // in/out
    SYSTEMTIME newRangeEnd; // in/out
    BOOL fCancel;           // out
} SFTDATE_NMVALIDATING, * LPSFTDATE_NMVALIDATING;

Members

hdr

The standard WM_NOTIFY notification header. hwndFrom contains the window handle of the date field control, idFrom its control ID and code is set to NM_SFTDATE_VALUEVALIDATING.

fHasValue

In: TRUE if newValue holds the new value, FALSE if the user is emptying the field. Out: the application can change it.

newValue

In: the new value, or the first date of the range in range selection mode. Out: the application can replace it.

fHasRangeEnd

In: TRUE if newRangeEnd holds a last date. The control passes its current last date in single selection mode too. Out: the application can change it.

newRangeEnd

In: the new last date of the range. Out: the application can replace it.

fCancel

Out: TRUE to refuse the change and keep the current value. The control sets it to FALSE.

Comments

The date field control sends the WM_NOTIFY message with the SFTDATE_NMVALIDATING structure to its parent window (or the window defined using SetNotifyWindow) when the user completes a change: a part typed, a value chosen in the dropdown, free-form text parsed, a value pasted, the field emptied or the Clear button used. Changes made by the application (SetValue, SetRange) are not validated.

Setting fCancel to TRUE keeps the current value; the field ends the editing and shows the current value again. Otherwise the application can change the value: a new value is moved into the range defined by SetMinDate and SetMaxDate, and a value without date (fHasValue FALSE) is refused if the field allows neither an empty value nor a check box. The control then sends NM_SFTDATE_VALUECHANGED.

An application that refuses a value can tell screen reader users why, using Announce.

case WM_NOTIFY: {
    LPNMHDR lpnmh = (LPNMHDR) lParam;
    if (lpnmh->idFrom == IDC_APPOINTMENT && lpnmh->code == NM_SFTDATE_VALUEVALIDATING) {
        LPSFTDATE_NMVALIDATING lpv = (LPSFTDATE_NMVALIDATING) lParam;
        // refuse Saturday and Sunday
        FILETIME ft;
        SYSTEMTIME st = lpv->newValue;
        SystemTimeToFileTime(&st, &ft);
        FileTimeToSystemTime(&ft, &st);     // sets wDayOfWeek
        if (lpv->fHasValue && (st.wDayOfWeek == 0 || st.wDayOfWeek == 6))
            lpv->fCancel = TRUE;
    }
    break;
 }

Examples

C View entire sample code

            FormatDate(&st, SftDate_GetValue(lpnmhdr->hwndFrom, &st), szValue);
        else
            GetWindowText(lpnmhdr->hwndFrom, szValue, 100);
        break;
    case NM_SFTDATE_RANGECHANGED:
        lpszCode = TEXT("NM_SFTDATE_RANGECHANGED");
        break;
    case NM_SFTDATE_VALUEVALIDATING: {
        LPSFTDATE_NMVALIDATING lpVal = (LPSFTDATE_NMVALIDATING) lpnmhdr;
        lpszCode = lpVal->fCancel ? TEXT("NM_SFTDATE_VALUEVALIDATING (canceled, a weekend)") : TEXT("NM_SFTDATE_VALUEVALIDATING");
        wsprintf(szData, TEXT("fHasValue=%d newValue=%s fHasRangeEnd=%d newRangeEnd=%s fCancel=%d"),
            lpVal->fHasValue, FormatDate(&lpVal->newValue, lpVal->fHasValue, szDate1),
            lpVal->fHasRangeEnd, FormatDate(&lpVal->newRangeEnd, lpVal->fHasRangeEnd, szDate2), lpVal->fCancel);
        break;
     }
    case NM_SFTDATE_TEXTPARSING: {

C++ View entire sample code

    FileTimeToSystemTime(&ft, &st);
    return st.wDayOfWeek;
}

/////////////////////////////////////////////////////////////////////////////
// Application logic

// Appointments are only accepted on weekdays.
static void ValidateAppointment(LPSFTDATE_NMVALIDATING lpVal)
{
    if (lpVal->fHasValue) {
        int day = DayOfWeek(lpVal->newValue);
        if (day == 0 || day == 6)
            lpVal->fCancel = TRUE;
    }
}

See Also C/C++ API | Categories | Notifications


Last Updated 11/26/2026 - (email)
© 2026 Softel vdm, Inc.