HeaderPane
Main
Hide
Share Link
Print

MinDate

Defines the earliest date a control accepts.

C

void WINAPI SftDate_GetMinDate(HWND hwndCtl, LPSYSTEMTIME lpValue);
BOOL WINAPI SftDate_SetMinDate(HWND hwndCtl, const SYSTEMTIME* lpValue);

C++

void CSftDate::GetMinDate(LPSYSTEMTIME lpValue) const;
void CSftCalendar::GetMinDate(LPSYSTEMTIME lpValue) const;
BOOL CSftDate::SetMinDate(const SYSTEMTIME* lpValue);
BOOL CSftCalendar::SetMinDate(const SYSTEMTIME* lpValue);

Parameters

hwndCtl

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

lpValue

GetMinDate: a pointer to a SYSTEMTIME structure that receives the earliest date.
SetMinDate: a pointer to a SYSTEMTIME structure that holds the earliest date.

Returns

SetMinDate returns TRUE if the date was set. FALSE is returned if lpValue is NULL or holds an invalid date, or if the date is later than the latest date (SetMaxDate).

Comments

The GetMinDate and SetMinDate functions define and retrieve the earliest date a control accepts. The default is January 1, 0001.

The user cannot enter, select or scroll to a date before the earliest date; earlier 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.

SetMaxDate defines the latest 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.

Examples

C View entire sample code

        ShowSelection(hwndDlg);
        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)

C++ View entire sample code

        m_Calendar.SetSelectionMode(fChecked ? SFTDATE_SELECTION_RANGE : SFTDATE_SELECTION_SINGLE);
        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)

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


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