Share via


CMonthCalCtrl::SetColor

Sets the color of a specified area of a month calendar control.

COLORREF SetColor( 
   int nRegion, 
   COLORREF ref  
);

Parameters

  • nRegion
    An integer value specifying which month calendar color to set. This value can be one of the following.

    Value

    Meaning

    MCSC_BACKGROUND

    The background color displayed between months.

    MCSC_MONTHBK

    The background color displayed within the month.

    MCSC_TEXT

    The color used to display text within a month.

    MCSC_TITLEBK

    The background color displayed in the calendar's title.

    MCSC_TITLETEXT

    The color used to display text within the calendar's title.

    MCSC_TRAILINGTEXT

    The color used to display header and trailing-day text. Header and trailing days are the days from the previous and following months that appear on the current calendar.

  • ref
    A COLORREF value for the new color setting for the specified portion of the month calendar control.

Return Value

A COLORREF value that represents the previous color setting for the specified portion of the month calendar control, if successful. Otherwise this message returns -1.

Remarks

This member function implements the behavior of the Win32 message MCM_SETCOLOR, as described in the Windows SDK.

Example

// Set colors for title text and title background to match 
// the Control Panel settings for inactive window captions.
m_calCtrl1.SetColor(MCSC_TITLETEXT, ::GetSysColor(COLOR_INACTIVECAPTIONTEXT));
m_calCtrl1.SetColor(MCSC_TITLEBK, ::GetSysColor(COLOR_INACTIVECAPTION));

Requirements

Header: afxdtctl.h

See Also

Reference

CMonthCalCtrl Class

Hierarchy Chart

CMonthCalCtrl::GetColor