HeaderPane
Main
Hide
Share Link
Print

SFTDATE_NMDAYFORMATTING Structure

The SFTDATE_NMDAYFORMATTING structure is sent with the NM_SFTDATE_DAYFORMATTING notification before a calendar shows a day, so the application can change how it is shown.

typedef struct tagSftDateNMDayFormatting {
    NMHDR hdr;
    SYSTEMTIME date;     // in
    BOOL fToday;         // in
    BOOL fWeekend;       // in
    BOOL fInRange;       // in
    int specialDate;     // in
    BOOL fEnabled;       // in/out
    BOOL fBold;          // in/out
    COLORREF colorBg;    // in/out
    COLORREF colorFg;    // in/out
    HFONT hFont;         // in/out
    SFT_PICTURE Picture; // in/out
    LPCTSTR lpszToolTip; // in/out
    LPCTSTR lpszText;    // in/out
} SFTDATE_NMDAYFORMATTING, * LPSFTDATE_NMDAYFORMATTING;

Members

hdr

The standard WM_NOTIFY notification header. hwndFrom contains the window handle of the month calendar control or date field control, idFrom its control ID and code is set to NM_SFTDATE_DAYFORMATTING.

date

In: the day (00:00:00).

fToday

In: TRUE if the day is today (SetTodayDate).

fWeekend

In: TRUE if the day is a Saturday or Sunday.

fInRange

In: TRUE if the day is within the range defined using SetMinDate and SetMaxDate. Days outside it are always disabled.

specialDate

In: the index of the special date that applies to the day (FindSpecialDate), or -1 for none.

fEnabled

In: FALSE if the day is disabled by SetDisabledDaysOfWeek, a special date or the range. Out: FALSE to disable the day.

fBold

In: TRUE if a special date shows the day in bold. Out: TRUE for bold text.

colorBg

In/out: the background color, or SFTDATE_NOCOLOR for none.

colorFg

In/out: the text color, or SFTDATE_NOCOLOR for the default color.

hFont

In/out: the font, or NULL for the calendar's font. The font must remain valid while the day is shown.

Picture

In/out: a picture shown in the top corner of the day (SFT_PICTURE), zero-filled for none. It must remain valid while the day is shown.

lpszToolTip

In/out: the tooltip text, or NULL for none. The control copies the text.

lpszText

In/out: a text shown instead of the day number, or NULL for the number. The control copies the text.

Comments

A month calendar control and the dropdown calendar of a date field control send the WM_NOTIFY message with the SFTDATE_NMDAYFORMATTING structure the first time they show a day. The members hold the formatting of the special date that applies (AddSpecialDate) and the application can change any of them. The result is kept until a setting or a special date changes or the application calls RefreshDays.

Colors can be RGB values or GetSysColor index values with the high-order bit set; RGB values are used as given in dark mode too. In high contrast mode, the colors are ignored. Pictures are scaled according to SetImageScaling.

case WM_NOTIFY: {
    LPNMHDR lpnmh = (LPNMHDR) lParam;
    if (lpnmh->code == NM_SFTDATE_DAYFORMATTING) {
        LPSFTDATE_NMDAYFORMATTING lpf = (LPSFTDATE_NMDAYFORMATTING) lParam;
        if (lpf->fWeekend && lpf->colorFg == SFTDATE_NOCOLOR)
            lpf->colorFg = RGB(178, 34, 34);    // weekends in red
    }
    break;
 }

Examples

C View entire sample code

        Layout(hwndDlg);
        return TRUE;

    case WM_NOTIFY: {
        LPNMHDR lpnmhdr = (LPNMHDR) lParam;
        switch (lpnmhdr->code) {
        case NM_SFTDATE_DAYFORMATTING: {
            // any day of any calendar can be changed here; this colors weekends that aren't special dates
            LPSFTDATE_NMDAYFORMATTING lpDay = (LPSFTDATE_NMDAYFORMATTING) lParam;
            if (IsDlgButtonChecked(hwndDlg, IDC_WEEKENDS) == BST_CHECKED && lpDay->fWeekend && lpDay->specialDate < 0)
                lpDay->colorFg = RGB(205, 92, 92);
            return TRUE;
         }
        case NM_SFTDATE_VALUECHANGED:
        case NM_SFTDATE_RANGECHANGED:
            if (lpnmhdr->idFrom == IDC_CALENDAR)

C++ View entire sample code

        if (Control(i).m_hWnd == pNMHDR->hwndFrom)
            SetColorScheme(Control(i), IsDlgButtonChecked(IDC_COLORS) == BST_CHECKED);
    *pResult = 0;
}

void CMainDlg::OnDayFormatting(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
    // any day of any calendar can be changed here; this colors weekends that aren't special dates
    LPSFTDATE_NMDAYFORMATTING lpDay = (LPSFTDATE_NMDAYFORMATTING) pNMHDR;
    if (IsDlgButtonChecked(IDC_WEEKENDS) == BST_CHECKED && lpDay->fWeekend && lpDay->specialDate < 0)
        lpDay->colorFg = RGB(205, 92, 92);
    *pResult = 0;
}

/////////////////////////////////////////////////////////////////////////////
// Initialization

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


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