Defines the latest date a control accepts.
C
void WINAPI SftDate_GetMaxDate(HWND hwndCtl, LPSYSTEMTIME lpValue); BOOL WINAPI SftDate_SetMaxDate(HWND hwndCtl, const SYSTEMTIME* lpValue);
C++
void CSftDate::GetMaxDate(LPSYSTEMTIME lpValue) const; void CSftCalendar::GetMaxDate(LPSYSTEMTIME lpValue) const; BOOL CSftDate::SetMaxDate(const SYSTEMTIME* lpValue); BOOL CSftCalendar::SetMaxDate(const SYSTEMTIME* lpValue);
hwndCtl
The window handle of the date field control (SftDate) or the month calendar control (SftCalendar).
lpValue
GetMaxDate: a pointer to a SYSTEMTIME structure that receives the latest date.
SetMaxDate: a pointer to a SYSTEMTIME structure that holds the latest date.
SetMaxDate returns TRUE if the date was set. FALSE is returned if lpValue is NULL or holds an invalid date, or if the date is earlier than the earliest date (SetMinDate).
The GetMaxDate and SetMaxDate functions define and retrieve the latest date a control accepts. The default is December 31, 9999.
The user cannot enter, select or scroll to a date after the latest date; later days are shown disabled in the calendar. A date field control applies the date and time, a month calendar control only the date. The date field control's dropdown calendar uses the same limits.
If the value or the selected range of the control lies outside the new limits, it is moved inside and the control sends the NM_SFTDATE_VALUECHANGED (or NM_SFTDATE_RANGECHANGED) notification.
SetMinDate defines the earliest date. SYSTEMTIME values are always Gregorian dates, regardless of the calendar system of the control's culture (SetCulture). The year must be between 1 and 9999 and all members must hold valid values; wDayOfWeek is ignored.
break;
case IDC_THISYEAR: {
SYSTEMTIME today, first, last;
GetLocalTime(&today);
first = MakeDate(today.wYear, 1, 1);
last = MakeDate(today.wYear, 12, 31);
for (i = 0; i < CONTROLS; ++i) {
SftDate_SetMinDate(c[i], fChecked ? &first : &g_minDate);
SftDate_SetMaxDate(c[i], fChecked ? &last : &g_maxDate);
}
ShowSelection(hwndDlg);
break;
}
case IDC_DROPONFOCUS:
for (i = 0; i < FIELDS; ++i)
SftDate_SetDropOnFocus(c[i], fChecked);
ShowSelection();
break;
case IDC_THISYEAR: {
SYSTEMTIME today;
GetLocalTime(&today);
SYSTEMTIME first = MakeDate(today.wYear, 1, 1), last = MakeDate(today.wYear, 12, 31);
for (int i = 0; i < CONTROLS; ++i) {
Control(i).SetMinDate(fChecked ? &first : &m_minDate);
Control(i).SetMaxDate(fChecked ? &last : &m_maxDate);
}
ShowSelection();
break;
}
case IDC_DROPONFOCUS:
for (int i = 0; i < FIELDS; ++i)
m_Fields[i].SetDropOnFocus(fChecked);See Also C/C++ API | Categories | Notifications