Month Calendar Control Reference

Month Calendar Control Reference


This section contains information about the following programming elements used with month calendar controls.

Month calendar control styles

Month calendar day numbers

Messages
MCM_GETCOLOR
MCM_GETCURSEL
MCM_GETFIRSTDAYOFWEEK
MCM_GETMAXSELCOUNT
MCM_GETMAXTODAYWIDTH
MCM_GETMINREQRECT
MCM_GETMONTHDELTA
MCM_GETMONTHRANGE
MCM_GETRANGE
MCM_GETSELRANGE
MCM_GETTODAY
MCM_GETUNICODEFORMAT
MCM_HITTEST
MCM_SETCOLOR
MCM_SETCURSEL
MCM_SETDAYSTATE
MCM_SETFIRSTDAYOFWEEK
MCM_SETMAXSELCOUNT
MCM_SETMONTHDELTA
MCM_SETRANGE
MCM_SETSELRANGE
MCM_SETTODAY
MCM_SETUNICODEFORMAT

Utility Macros
MonthCal_GetColor
MonthCal_GetCurSel
MonthCal_GetFirstDayOfWeek
MonthCal_GetMaxSelCount
MonthCal_GetMaxTodayWidth
MonthCal_GetMinReqRect
MonthCal_GetMonthDelta
MonthCal_GetMonthRange
MonthCal_GetRange
MonthCal_GetSelRange
MonthCal_GetToday
MonthCal_GetUnicodeFormat
MonthCal_HitTest
MonthCal_SetColor
MonthCal_SetCurSel
MonthCal_SetDayState
MonthCal_SetFirstDayOfWeek
MonthCal_SetMaxSelCount
MonthCal_SetMonthDelta
MonthCal_SetRange
MonthCal_SetSelRange
MonthCal_SetToday
MonthCal_SetUnicodeFormat

Notifications
MCN_GETDAYSTATE
MCN_SELCHANGE
MCN_SELECT
NM_RELEASEDCAPTURE (monthcal)

Structures and Data Types
MCHITTESTINFO
MONTHDAYSTATE
NMDAYSTATE
NMSELCHANGE

Month Calendar Control Constants

This section contains information about the constants used with month calendar controls.

Month calendar control styles

The following are the styles used with month calendar controls.
MCS_DAYSTATE Version 4.70. The month calendar will send MCN_GETDAYSTATE notifications to request information about which days should be displayed in bold. For more information about supporting this style, see Processing the MCN_GETDAYSTATE Notification Message.
MCS_MULTISELECT Version 4.70. The month calendar will allow the user to select a range of dates within the control. By default, the maximum range is one week. You can change the maximum range that can be selected by using the MCM_SETMAXSELCOUNT message.
MCS_NOTODAY Version 4.70. The month calendar control will not display the "today" date at the bottom of the control.
MCS_NOTODAYCIRCLE Version 4.70. The month calendar control will not circle the "today" date.
MCS_WEEKNUMBERS Version 4.70. The month calendar control will display week numbers (1-52) to the left of each row of days.

Month calendar day numbers

The following list contains the numeric representations of the days of the week that are used by the month calendar control.
Value Day of Week
0 Monday
1 Tuesday
2 Wednesday
3 Thursday
4 Friday
5 Saturday
6 Sunday

Month Calendar Control Messages

This section contains information about the messages used with month calendar controls.

MCM_GETCOLOR

MCM_GETCOLOR
    wParam = (WPARAM)(INT)iColor;
    lParam = 0;

Retrieves the color for a given portion of a month calendar control. You can send this message explicitly or by using the MonthCal_GetColor macro.

iColor
INT value specifying which month calendar color to retrieve. This value can be one of the following:
MCSC_BACKGROUND Retrieve the background color displayed between months.
MCSC_MONTHBK Retrieve the background color displayed within the month.
MCSC_TEXT Retrieve the color used to display text within a month.
MCSC_TITLEBK Retrieve the background color displayed in the calendar's title.
MCSC_TITLETEXT Retrieve the color used to display text within the calendar's title.
MCSC_TRAILINGTEXT Retrieve the color used to display header day and trailing day text. Header and trailing days are the days from the previous and following months that appear on the current month calendar.

Version 4.70

MCM_GETCURSEL

MCM_GETCURSEL
    wParam = 0;
    lParam = (LPARAM) (LPSYSTEMTIME) lpSysTime;

Retrieves the currently selected date. You can send this message explicitly or by using the MonthCal_GetCurSel macro.

lpSysTime
Address of a SYSTEMTIME structure that will receive the currently selected date information. This parameter must be a valid address and cannot be NULL.

Version 4.70

See also Times in the Month Calendar Control

MCM_GETFIRSTDAYOFWEEK

MCM_GETFIRSTDAYOFWEEK
    wParam = 0;
    lParam = 0;

Retrieves the first day of the week for a month calendar control. You can send this message explicitly or by using the MonthCal_GetFirstDayOfWeek macro.

Version 4.70

MCM_GETMAXSELCOUNT

MCM_GETMAXSELCOUNT
    wParam = 0;
    lParam = 0;

Retrieves the maximum date range that can be selected in a month calendar control. You can send this message explicitly or by using the MonthCal_GetMaxSelCount macro.

You can change the maximum date range that can be selected by using the MCM_SETMAXSELCOUNT message.

Version 4.70

MCM_GETMAXTODAYWIDTH

MCM_GETMAXTODAYWIDTH
    wParam = 0;
    lParam = 0;

Retrieves the maximum width of the "today" string in a month calendar control. This includes the label text and the date text. You can send this message explicitly or by using the MonthCal_GetMaxTodayWidth macro.

Version 4.70

MCM_GETMINREQRECT

MCM_GETMINREQRECT
    wParam = 0;
    lParam = (LPARAM) (LPRECT) lpRectInfo;

Retrieves the minimum size required to display a full month in a month calendar control. Size information is presented in the form of a RECT structure. You can send this message explicitly or by using the MonthCal_GetMinReqRect macro.

lpRectInfo
Address of a RECT structure that will receive bounding rectangle information. This parameter must be a valid address and cannot be NULL.

The top and left members of lpRectInfo will always be zero. The right and bottom members represent the minimum cx and cy required for the control.

The minimum required window size for a month calendar control depends on the currently selected font.

Version 4.70

MCM_GETMONTHDELTA

MCM_GETMONTHDELTA
    wParam = 0;
    lParam = 0;

Retrieves the scroll rate for a month calendar control. The scroll rate is the number of months that the control moves its display when the user clicks a scroll button. You can send this message explicitly or by using the MonthCal_GetMonthDelta macro.

Version 4.70

MCM_GETMONTHRANGE

MCM_GETMONTHRANGE
    wParam = (WPARAM)(DWORD) dwFlag;
    lParam = (LPARAM)(LPSYSTEMTIME) lprgSysTimeArray;

Retrieves date information (using SYSTEMTIME structures) that represents the high and low limits of a month calendar control's display. You can send this message explicitly or by using the MonthCal_GetMonthRange macro.

dwFlag
Value specifying the scope of the range limits to be retrieved. This value must be one of the following:
GMR_DAYSTATE Include preceding and trailing months of visible range that are only partially displayed.
GMR_VISIBLE Include only those months that are entirely displayed.
lprgSysTimeArray
Address of a two-element array of SYSTEMTIME structures that will receive the lower and upper limits of the scope specified by dwFlag. The lower and upper limits are placed in lprgSysTimeArray[0] and lprgSysTimeArray[1], respectively. This parameter must be a valid address and cannot be NULL.

Version 4.70

See also Times in the Month Calendar Control

MCM_GETRANGE

MCM_GETRANGE
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lprgSysTimeArray;

Retrieves the minimum and maximum allowable dates set for a month calendar control. You can send this message explicitly or by using the MonthCal_GetRange macro.

lprgSysTimeArray
Address of a two-element array of SYSTEMTIME structures that will receive the date limit information. The minimum limit is set in lprgSysTimeArray[0], and lprgSysTimeArray[1] receives the maximum limit. If either element is set to all zeros, then no corresponding limit is set for the month calendar control. This parameter must be a valid address and cannot be NULL.

Version 4.70

See also Times in the Month Calendar Control

MCM_GETSELRANGE

MCM_GETSELRANGE
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lprgSysTimeArray;

Retrieves date information that represents the upper and lower limits of the date range currently selected by the user. You can send this message explicitly or by using the MonthCal_GetSelRange macro.

lprgSysTimeArray
Address of a two-element array of SYSTEMTIME structures that will receive the lower and upper limits of the user's selection. The lower and upper limits are placed in lprgSysTimeArray[0] and lprgSysTimeArray[1], respectively. This parameter must be a valid address and cannot be NULL.

Version 4.70

See also Times in the Month Calendar Control

MCM_GETTODAY

MCM_GETTODAY
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lpToday;

Retrieves the date information for the date specified as "today" for a month calendar control. You can send this message explicitly or by using the MonthCal_GetToday macro.

lpToday
Address of a SYSTEMTIME structure that will receive the date information. This parameter must be a valid address and cannot be NULL.

Version 4.70

See also Times in the Month Calendar Control

MCM_GETUNICODEFORMAT

MCM_GETUNICODEFORMAT
    wParam = 0;
    lParam = 0;

Retrieves the UNICODE character format flag for the control. You can send this message explicitly or use the MonthCal_GetUnicodeFormat macro.

See also MCM_SETUNICODEFORMAT

MCM_HITTEST

MCM_HITTEST
    wParam = 0;
    lParam = (LPARAM)(PMCHITTESTINFO) pMCHitTest;

Determines which portion of a month calendar control is at a given point on the screen. You can send this message explicitly or by using the MonthCal_HitTest macro.

pMCHitTest
Address of an MCHITTESTINFO structure. Upon sending the message, the cbSize member must be set to the size of the MCHITTESTINFO structure, and pt must be set to the point you want to hit test.

Version 4.70

MCM_SETCOLOR

MCM_SETCOLOR
    wParam = (WPARAM)(INT) iColor;
    lParam = (LPARAM)(COLORREF) clr;

Sets the color for a given portion of a month calendar control. You can send this message explicitly or by using the MonthCal_SetColor macro.

iColor
INT value specifying which month calendar color to set. This value can be one of the following:
MCSC_BACKGROUND Retrieve the background color displayed between months.
MCSC_MONTHBK Retrieve the background color displayed within the month.
MCSC_TEXT Retrieve the color used to display text within a month.
MCSC_TITLEBK Retrieve the background color displayed in the calendar's title.
MCSC_TITLETEXT Retrieve the color used to display text within the calendar's title.
MCSC_TRAILINGTEXT Retrieve the color used to display header day and trailing day text. Header and trailing days are the days from the previous and following months that appear on the current month calendar.
clr
COLORREF value that represents the color that will be set for the specified area of the month calendar.

Version 4.70

MCM_SETCURSEL

MCM_SETCURSEL
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lpSysTime;

Sets the currently selected date for a month calendar control. If the specified date is not in view, the control updates the display to bring it into view. You can send this message explicitly or by using the MonthCal_SetCurSel macro.

lpSysTime
Address of a SYSTEMTIME structure that contains the date to be set as the current selection.

Version 4.70

See also Times in the Month Calendar Control

MCM_SETDAYSTATE

MCM_SETDAYSTATE
    wParam = (WPARAM) iMonths;
    lParam = (LPARAM)(LPMONTHDAYSTATE) lpDayStateArray; 

Sets the day states for all months that are currently visible within a month calendar control. You can send this message explicitly or by using the MonthCal_SetDayState macro.

iMonths
Value indicating how many elements are in the array that lpDayStateArray points to.
lpDayStateArray
Address of an array of MONTHDAYSTATE values that define how the month calendar control will draw each day in its display.

The array at lpDayStateArray must contain as many elements as the value returned by the following macro:

MonthCal_GetMonthRange(hwndMC, GMR_DAYSTATE, NULL);

Keep in mind that the array at lpDayStateArray must contain MONTHDAYSTATE values that correspond with all months currently in the control's display, in chronological order. This includes the two months only partially displayed before the first month and after the last month. For more information about preparing your array, see Preparing the MONTHDAYSTATE Array.

Version 4.70

MCM_SETFIRSTDAYOFWEEK

MCM_SETFIRSTDAYOFWEEK
    wParam = 0;
    lParam = (LPARAM)(INT) iDay;

Sets the first day of the week for a month calendar control. You can send this message explicitly or by using the MonthCal_SetFirstDayOfWeek macro.

iDay
INT value representing which day is to be set as the first day of the week. This value must be one of the day numbers.

If the first day of the week is set to anything other than the default (LOCALE_IFIRSTDAYOFWEEK), the control will not automatically update first-day-of-the-week changes based on locale changes.

Version 4.70

MCM_SETMAXSELCOUNT

MCM_SETMAXSELCOUNT
    wParam = (WPARAM)(INT) iMax;
    lParam = 0;

Sets the maximum number of days that can be selected in a month calendar control. You can send this message explicitly or by using the MonthCal_SetMaxSelCount macro.

iMax
INT value that will be set to represent the maximum number of days that can be selected.

Version 4.70

MCM_SETMONTHDELTA

MCM_SETMONTHDELTA
    wParam = (WPARAM)(INT) iDelta;
    lParam = 0;

Sets the scroll rate for a month calendar control. The scroll rate is the number of months that the control moves its display when the user clicks a scroll button. You can send this message explicitly or by using the MonthCal_SetMonthDelta macro.

iDelta
Value representing the number of months to be set as the control's scroll rate. If this value is zero, the month delta is reset to the default, which is the number of months displayed in the control.

Version 4.70

MCM_SETRANGE

MCM_SETRANGE
    wParam = (WPARAM)(SHORT) fWhichLimit;
    lParam = (LPARAM)(LPSYSTEMTIME) lprgSysTimeArray;

Sets the minimum and maximum allowable dates for a month calendar control. You can send this message explicitly or by using the MonthCal_SetRange macro.

fWhichLimit
Flag values that specify which date limits are being set. This value must be one or both of the following:
GDTR_MAX The maximum allowable date is being set. The SYSTEMTIME structure at lprgSysTimeArray[1] must contain date information.
GDTR_MIN The minimum allowable date is being set. The SYSTEMTIME structure at lprgSysTimeArray[0] must contain date information.
lprgSysTimeArray
Address of a two-element array of SYSTEMTIME structures that contain the date limits. The maximum limit must be in lpSysTimeArray[1] if GDTR_MAX is specified, and lpSysTimeArray[0] must contain the minimum limit if GDTR_MIN is specified.

Version 4.70

See also Times in the Month Calendar Control

MCM_SETSELRANGE

MCM_SETSELRANGE
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lprgSysTimeArray;

Sets the selection for a month calendar control to a given date range. You can send this message explicitly or by using the MonthCal_SetSelRange macro.

lprgSysTimeArray
Address of a two-element array of SYSTEMTIME structures that contain date information representing the selection limits. The first selected date must be specified in lpSysTimeArray[0], and the last selected date must be specified in lpSysTimeArray[1].

Version 4.70

See also Times in the Month Calendar Control

MCM_SETTODAY

MCM_SETTODAY
    wParam = 0;
    lParam = (LPARAM)(LPSYSTEMTIME) lpSysTime;

Sets the "today" selection for a month calendar control. You can send this message explicitly or by using the MonthCal_SetToday macro.

lpSysTime
Address of a SYSTEMTIME structure that contains the date to be set as the "today" selection for the control. If this parameter is set to NULL, the control returns to the default setting.

If the "today" selection is set to any date other than the default, the following conditions apply:

Version 4.70

See also Times in the Month Calendar Control

MCM_SETUNICODEFORMAT

MCM_SETUNICODEFORMAT
    wParam = (WPARAM)(BOOL)fUnicode;
    lParam = 0;

Sets the UNICODE character format flag for the control. This message allows you to change the character set used by the control at run time rather than having to re-create the control. You can send this message explicitly or use the MonthCal_SetUnicodeFormat macro.

fUnicode
Determines the character set that is used by the control. If this value is nonzero, the control will use UNICODE characters. If this value is zero, the control will use ANSI characters.

See also MCM_GETUNICODEFORMAT

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.