Creating a Month Calendar Control

A month calendar control is a child window that displays a monthly calendar. The calendar can display one or more months at a time. The following screen shot shows a month calendar control.

When a user taps the name of a month with the stylus, a pop-up menu appears that lists all the months of the year. A user can select a month by tapping its name on the menu. A user who is using the date and time picker control can use ALT+DOWN ARROW to activate the month calendar control. A user can scroll the displayed months forward or backward either by tapping the left arrow or right arrow at the top of the control or by pressing the PAGE UP or PAGE DOWN keys on the keyboard. When a user taps the year displayed at the top of the calendar next to the month, an up-down control appears. A user can use this control to change the year. A user can also use CTRL+PAGE UP or CTRL+PAGE DOWN to scroll from one year to another. A user can press keys on the keyboard to navigate; the arrow keys scroll between days, the HOME key moves to the beginning of a month, and the END key moves to the end of a month. Unless the calendar has the MCS_NOTODAY style, a user can return to the current day by tapping the Today label at the bottom of the month calendar control.

    To create a month calendar control

  1. Specify MONTHCAL_CLASS in the lpClassName parameter of the CreateWindowEx function.

    This class is registered when the common control DLL is loaded. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the date and time picker class using the InitCommonControlsEx function, specify the ICC_DATE_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter.

  2. Specify a date and time picker style in the dwStyle parameter of the CreateWindowEx function.

    A month calendar control that uses the MCS_DAYSTATE style supports day states. The control uses day state data to determine how it draws specific days within the control. Day state data is expressed as a 32-bit data type, MONTHDAYSTATE. Each bit in a MONTHDAYSTATE bit field, from 1 through 31, represents the state of a day in a month. If a bit is on, the corresponding day will be displayed in bold; otherwise, it will be displayed with no emphasis. An application can explicitly set day state data by sending the MCM_SETDAYSTATE message or by using the corresponding macro, MonthCal_SetDayState. Additionally, month calendar controls that use the MCS_DAYSTATE style send MCN_GETDAYSTATE notification messages to request day state data. For a complete listing of supported styles, see Window and Control Styles.