HeaderPane
Main

Compare

An MFC date and time picker that can be empty

CDateTimeCtrl leaves a date out only through its check box, takes its formats from the Windows regional settings and sets a time with up and down buttons. CMonthCalCtrl marks days in bold and nothing more. Here is how both compare with SftDate/DLL 2.0, for C and C++ applications.

The problem

The date and time picker control, which CDateTimeCtrl wraps, is fine for a date every record has. An optional date needs the DTS_SHOWNONE style: the field gets a check box, and while it is cleared GetTime returns GDT_NONE and the field still shows a date.

More gaps show up as the application grows. The formats come from the Windows user's regional settings, not from a locale the application chooses, and a custom format set with SetFormat stops following changes to them. A time is set by typing or with the up-down control. The month calendar control, which CMonthCalCtrl wraps, marks days in bold only, selects at most a week unless the application raises the limit, and cannot rule out weekends or holidays. While visual styles are active, it ignores every color except the background.

SftDate/DLL 2.0 is a date field (SftDate) and a month calendar (SftCalendar) for C, C++ and MFC, with these features built in.

Feature comparison

FeatureCDateTimeCtrlCMonthCalCtrlSftDate/DLL 2.0
Empty valueOnly with the DTS_SHOWNONE check box, while the field still shows a dateNo, a date is always selectedA check box, or an empty field with placeholder text and a Clear button
CultureThe Windows user's regional formatsThe Windows user's regional formats, with a calendar system set by MCM_SETCALIDAny locale and any calendar it offers, set per control, including the Japanese, Hebrew and Hijri calendars and right-to-left layout
Choosing a timeTyping, or the up-down controlNoA time list or a clock face in the dropdown, alone or with the calendar
Date rangesNo, two pickersYes, one week unless MCM_SETMAXSELCOUNT raises the limitIn a field or a calendar, of any length or up to a maximum
Holidays and appointmentsNot built inBold days, supplied through MCN_GETDAYSTATEBold, colors, pictures and tooltips, recurring weekly, monthly or annually, in the dropdown too
Days that cannot be selectedNo, only a range set by SetRangeNo, only a range set by SetRangeDays of the week, single dates, or any rule in a notification
Months shownOne in the dropdownSeveralSeveral, in the calendar and in the dropdown
Week numbersOnly through a month calendar style for the dropdown (DTM_SETMCSTYLE)Yes, week 1 is the first week with at least four daysYes, by the culture's rule or ISO 8601
Typing a dateOne field at a time; with DTS_APPCANPARSE the user edits the text after F2 and your code parses itNoOne part at a time, or the whole date as text in the field's culture, with your own parsing if you need it
Refusing or correcting a value as it is enteredNo, DTN_DATETIMECHANGE follows the changeNo, MCN_SELCHANGE follows the changeNM_SFTDATE_VALUEVALIDATING notification
ColorsThe dropdown calendar's, as in CMonthCalCtrlIgnored except the background while visual styles are activeEvery color of the field, the calendar and single days

What the code looks like

The controls are window classes driven by exported functions, the same way as the common controls. This sets up an optional due date that shows a placeholder while it is empty, blocks weekends in its dropdown calendar and marks a holiday:

SFTDATE_SPECIALDATE sd;
SYSTEMTIME due;

SftDate_SetAllowEmpty(hwndDue, TRUE);
SftDate_SetPlaceholderText(hwndDue, TEXT("No due date"));
SftDate_SetShowClearButton(hwndDue, TRUE);
SftDate_SetValue(hwndDue, NULL);                  /* empty */
SftDate_SetDisabledDaysOfWeek(hwndDue, SFTDATE_DAYS_WEEKEND);

memset(&sd, 0, sizeof(sd));
sd.cbSize = sizeof(SFTDATE_SPECIALDATE);
sd.date.wYear = 2026;
sd.date.wMonth = 12;
sd.date.wDay = 25;
sd.recurrence = SFTDATE_RECURRENCE_ANNUALLY;
sd.fBold = TRUE;
sd.colorBg = SFTDATE_NOCOLOR;
sd.colorFg = RGB(178, 34, 34);
sd.lpszToolTip = TEXT("Christmas Day");
sd.fEnabled = TRUE;
SftDate_AddSpecialDate(hwndDue, &sd);

if (SftDate_GetValue(hwndDue, &due))
    ...                                           /* a due date */
else
    ...                                           /* no due date */

The disabled days apply to the calendar. A date the user types goes through the NM_SFTDATE_VALUEVALIDATING notification, which can refuse it:

case WM_NOTIFY: {
    LPNMHDR lpnmhdr = (LPNMHDR) lParam;
    if (lpnmhdr->idFrom == IDC_DUE && 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;
}

MFC applications use the supplied C++ classes CSftDate and CSftCalendar, which come with source code: m_Due.SetAllowEmpty(TRUE), m_Due.AddSpecialDate(&sd). The product includes samples for C and for MFC, and an API reference written for AI coding assistants.

Modern Windows

SftDate/DLL 2.0 supports 32-bit and 64-bit applications on Windows 10 and later and ARM64 applications on Windows 11, with ANSI and UNICODE DLLs, and static libraries for 32-bit and 64-bit Intel applications that eliminate the DLL. The field, its dropdown and the calendar follow the Windows light/dark setting and the Windows contrast themes when set to do so, scale with the DPI of the monitor showing them, support right-to-left layout and have a built-in UI Automation provider for Narrator, NVDA, JAWS and other screen readers, dropdown included.

When the common controls are enough

If a dialog needs a required date in the user's own regional format and nothing more, CDateTimeCtrl is fine, and it is part of Windows. SftDate/DLL earns its place when dates are optional, when the application decides the culture, when users pick times, ranges or days from a calendar that shows holidays and blocks days, or when the field has to match a dark or custom-colored application.

Try it

Download the free trial and test it in your own application before you buy. A license is royalty-free in run-time mode and includes one year of support and upgrades.

SftDate/DLL 2.0 and free trial Documentation