HeaderPane
Main
Hide
Share Link
Print

Date Ranges

With SftDate_SetSelectionMode set to SFTDATE_SELECTION_RANGE, a field or a calendar holds a range of dates instead of one date. A range can have any length, from one day to many years; SftDate_SetMaxRangeDays can limit it to a number of days (0, the default, means no limit). The limit applies to the selection in a calendar, including the dropdown calendar of a field.

Range Fields

An SftDate control in range mode shows the first and the last date of the range, separated by the text defined by SftDate_SetRangeSeparator (by default, an en dash with a space on either side). Both dates are edited part by part like a single date, and Tab moves through the parts of both. As the two dates are edited independently, the last date can end up before the first; an application that doesn't accept this refuses or swaps the dates in the NM_SFTDATE_VALUEVALIDATING notification. A range chosen in the dropdown calendar is always in order. SftDate_GetRangeStart and SftDate_GetRangeEnd return the two dates, SftDate_SetRange sets them, and SftDate_GetValue returns the first date. The NM_SFTDATE_RANGECHANGED notification is sent when either date changes, NM_SFTDATE_VALUECHANGED when the first date changes.

The dropdown of a range field shows at least two months. The user clicks the first and then the last date of the range, and the dropdown closes after the second click; until then, the days up to the date under the mouse are shown as the range. The arrow keys move the focus in the dropdown calendar without changing the range. Space selects the focused day like a click: the first time as the first date, the second time as the last date, which closes the dropdown. Enter accepts the range, and when only its first date was selected, a range of one day.

Range Calendars

In an SftCalendar control in range mode, SftDate_GetRangeStart and SftDate_GetRangeEnd return the selected range, and SftDate_SetRange selects one. The NM_SFTDATE_RANGECHANGED notification is sent when the range changes, and NM_SFTDATE_VALUECHANGED when its first date changes. The days between the first and the last day are shown in the SFTDATE_COLOR_RANGEBACK color.

The user selects a range with the mouse or the keyboard:

  • A click selects one day and starts a new range.
  • Shift+click extends the range to the clicked day, and dragging the mouse selects the days it passes over.
  • A click on a week number selects the week.
  • Shift with the arrow keys, Page Up, Page Down, Home and End extends the range.

SftDate_GetRangeStart and SftDate_GetRangeEnd always return the earlier date first, also when the user selects backward.

SYSTEMTIME first = { 2026, 11, 0, 23 }, last = { 2026, 12, 0, 11 };
SftDate_SetSelectionMode(hwndCalendar, SFTDATE_SELECTION_RANGE);
SftDate_SetRange(hwndCalendar, &first, &last);

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