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
| Feature | CDateTimeCtrl | CMonthCalCtrl | SftDate/DLL 2.0 |
|---|---|---|---|
| Empty value | Only with the DTS_SHOWNONE check box, while the field still shows a date | No, a date is always selected | A check box, or an empty field with placeholder text and a Clear button |
| Culture | The Windows user's regional formats | The Windows user's regional formats, with a calendar system set by MCM_SETCALID | Any locale and any calendar it offers, set per control, including the Japanese, Hebrew and Hijri calendars and right-to-left layout |
| Choosing a time | Typing, or the up-down control | No | A time list or a clock face in the dropdown, alone or with the calendar |
| Date ranges | No, two pickers | Yes, one week unless MCM_SETMAXSELCOUNT raises the limit | In a field or a calendar, of any length or up to a maximum |
| Holidays and appointments | Not built in | Bold days, supplied through MCN_GETDAYSTATE | Bold, colors, pictures and tooltips, recurring weekly, monthly or annually, in the dropdown too |
| Days that cannot be selected | No, only a range set by SetRange | No, only a range set by SetRange | Days of the week, single dates, or any rule in a notification |
| Months shown | One in the dropdown | Several | Several, in the calendar and in the dropdown |
| Week numbers | Only through a month calendar style for the dropdown (DTM_SETMCSTYLE) | Yes, week 1 is the first week with at least four days | Yes, by the culture's rule or ISO 8601 |
| Typing a date | One field at a time; with DTS_APPCANPARSE the user edits the text after F2 and your code parses it | No | One 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 entered | No, DTN_DATETIMECHANGE follows the change | No, MCN_SELCHANGE follows the change | NM_SFTDATE_VALUEVALIDATING notification |
| Colors | The dropdown calendar's, as in CMonthCalCtrl | Ignored except the background while visual styles are active | Every 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.
