HeaderPane
Main
Hide
Share Link
Print

SelectionMode

Defines whether a control holds one date or a range of dates.

C

int WINAPI SftDate_GetSelectionMode(HWND hwndCtl);
BOOL WINAPI SftDate_SetSelectionMode(HWND hwndCtl, int mode);

C++

int CSftDate::GetSelectionMode() const;
int CSftCalendar::GetSelectionMode() const;
BOOL CSftDate::SetSelectionMode(int mode);
BOOL CSftCalendar::SetSelectionMode(int mode);

Parameters

hwndCtl

The window handle of the date field control (SftDate) or the month calendar control (SftCalendar).

mode

Defines the selection mode. mode can be one of the following values:

SFTDATE_SELECTION_SINGLEThe control holds one date. This is the default.
SFTDATE_SELECTION_RANGEThe control holds a range of dates (GetRangeStart, GetRangeEnd).

Returns

GetSelectionMode returns the current selection mode.

SetSelectionMode returns TRUE if the mode is valid, otherwise FALSE.

Comments

The GetSelectionMode and SetSelectionMode functions define and retrieve the selection mode of a control.

In range selection mode, a month calendar control lets the user select a range of days and a date field control shows and edits two dates, separated by the text defined using SetRangeSeparator, with a dropdown calendar that selects a range. The value of the control (GetValue) is the first date of the range.

SetMaxRangeDays limits the number of days the user can select. The selected range is reported using the NM_SFTDATE_RANGECHANGED notification.

Examples

C View entire sample code

static void ShowSelection(HWND hwndDlg)
{
    HWND hwndCal = GetDlgItem(hwndDlg, IDC_CALENDAR);
    WCHAR szText[200], szFirst[80], szLast[80];
    SYSTEMTIME start, end;

    lstrcpyW(szText, L"Selected: (none)");
    if (SftDate_GetSelectionMode(hwndCal) == SFTDATE_SELECTION_RANGE) {
        if (SftDate_GetRangeStart(hwndCal, &start)) {
            if (!SftDate_GetRangeEnd(hwndCal, &end))
                end = start;
            FormatLongDate(hwndDlg, &start, szFirst, 80);
            FormatLongDate(hwndDlg, &end, szLast, 80);
            wsprintfW(szText, L"Selected: %s - %s", szFirst, szLast);
        }
    } else if (SftDate_GetValue(hwndCal, &start)) {

C++ View entire sample code

        szText[0] = 0;
    return szText;
}

void CMainDlg::ShowSelection()
{
    CString text = _T("Selected: (none)");
    SYSTEMTIME start, end;
    if (m_Calendar.GetSelectionMode() == SFTDATE_SELECTION_RANGE) {
        if (m_Calendar.GetRangeStart(&start)) {
            if (!m_Calendar.GetRangeEnd(&end))
                end = start;
            text = _T("Selected: ") + FormatLongDate(start) + _T(" - ") + FormatLongDate(end);
        }
    } else if (m_Calendar.GetValue(&start))
        text = _T("Selected: ") + FormatLongDate(start);

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


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