HeaderPane
Main
Hide
Share Link
Print

SFTDATE_NMTEXTPARSING Structure

The SFTDATE_NMTEXTPARSING structure is sent with the NM_SFTDATE_TEXTPARSING notification before a date field control parses a text, so the application can parse it instead.

typedef struct tagSftDateNMTextParsing {
    NMHDR hdr;
    LPCTSTR lpszText;   // in
    BOOL fHasCurrent;   // in
    SYSTEMTIME current; // in
    BOOL fHandled;      // out
    BOOL fHasValue;     // out
    SYSTEMTIME value;   // out
} SFTDATE_NMTEXTPARSING, * LPSFTDATE_NMTEXTPARSING;

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_TEXTPARSING.

lpszText

In: the text typed or pasted. In range selection mode, the text of one of the two dates.

fHasCurrent

In: TRUE if current holds the current value.

current

In: the current value (or date of the range) the text replaces, for texts relative to it.

fHandled

Out: TRUE if the application parsed the text. The control sets it to FALSE.

fHasValue

Out: TRUE if value holds the result. FALSE together with fHandled rejects the text.

value

Out: the parsed value.

Comments

The date field control sends the WM_NOTIFY message with the SFTDATE_NMTEXTPARSING structure when it parses a text: the text typed in free-form editing (SetEditStyle), a value pasted from the clipboard and the text set using WM_SETTEXT.

If the application leaves fHandled FALSE, the control parses the text itself: in the format of the field, then leniently in the formats of the culture, and the texts "=Today", "=Yesterday", "=Tomorrow" and "=Now". A value the application or the control parsed is then validated (NM_SFTDATE_VALUEVALIDATING), except for WM_SETTEXT.

The text pointer is valid only during the notification. In ANSI builds, the text is converted using the system code page.

case WM_NOTIFY: {
    LPNMHDR lpnmh = (LPNMHDR) lParam;
    if (lpnmh->idFrom == IDC_DUEDATE && lpnmh->code == NM_SFTDATE_TEXTPARSING) {
        LPSFTDATE_NMTEXTPARSING lpp = (LPSFTDATE_NMTEXTPARSING) lParam;
        // "+3" is three days from today, "-1" yesterday
        int days;
        if ((lpp->lpszText[0] == '+' || lpp->lpszText[0] == '-') && _stscanf_s(lpp->lpszText, TEXT("%d"), &days) == 1) {
            FILETIME ft;
            ULARGE_INTEGER u;
            GetLocalTime(&lpp->value);
            lpp->value.wHour = lpp->value.wMinute = lpp->value.wSecond = lpp->value.wMilliseconds = 0;
            SystemTimeToFileTime(&lpp->value, &ft);
            u.LowPart = ft.dwLowDateTime; u.HighPart = ft.dwHighDateTime;
            u.QuadPart += (LONGLONG)days * 24 * 60 * 60 * 10000000;
            ft.dwLowDateTime = u.LowPart; ft.dwHighDateTime = u.HighPart;
            FileTimeToSystemTime(&ft, &lpp->value);
            lpp->fHasValue = TRUE;
            lpp->fHandled = TRUE;
        }
    }
    break;
 }

Examples

C View entire sample code

        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: {
        LPSFTDATE_NMTEXTPARSING lpParse = (LPSFTDATE_NMTEXTPARSING) lpnmhdr;
        lpszCode = TEXT("NM_SFTDATE_TEXTPARSING");
        wsprintf(szData, TEXT("lpszText=%.80s fHasCurrent=%d current=%s fHandled=%d fHasValue=%d value=%s"),
            lpParse->lpszText, lpParse->fHasCurrent, FormatDate(&lpParse->current, lpParse->fHasCurrent, szDate1),
            lpParse->fHandled, lpParse->fHasValue, FormatDate(&lpParse->value, lpParse->fHasValue, szDate2));
        break;
     }
    case NM_SFTDATE_DROPDOWNOPENING:

C++ View entire sample code

    if (lpVal->fHasValue) {
        int day = DayOfWeek(lpVal->newValue);
        if (day == 0 || day == 6)
            lpVal->fCancel = TRUE;
    }
}

// Besides dates in the culture's format, the due date accepts +n and -n days from today.
static void ParseDueDate(LPSFTDATE_NMTEXTPARSING lpParse)
{
    CString text = lpParse->lpszText;
    text.Remove(_T(' '));
    if (text.GetLength() < 2 || text.GetLength() > 5 || (text[0] != _T('+') && text[0] != _T('-')))
        return;
    if (text.Mid(1).SpanIncluding(_T("0123456789")) != text.Mid(1))
        return;

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


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