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);
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_SINGLE | The control holds one date. This is the default. |
| SFTDATE_SELECTION_RANGE | The control holds a range of dates (GetRangeStart, GetRangeEnd). |
GetSelectionMode returns the current selection mode.
SetSelectionMode returns TRUE if the mode is valid, otherwise FALSE.
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.
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)) {
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