﻿# Month Calendar Control

_Updated December 2018; see History_

The month calendar control is essentially the same as the calendar that appears in a date picker when you press the dropdown button, but is not associated with an input field, thus making it suitable to just place in a window/dialog as a convenience to the user in applications that involve dates (like scheduling). In comparison to the generic date/time dialog (the one you get by double-clicking on the system time display), this one has the advantage of being visually more compact, as well as providing some degree of application control. For example, you can:

•	generate a key click string/exitcode when the user changes the date

•	query or set the selected date (independent of the system date)

•	you can set limits on the range of dates that can be selected or displayed

•	highlight individual dates

To create a calendar control, use the following syntax:

**xcall AUI, AUI\_CONTROL, CTLOP\_ADD, ctlid, ctext\$, cstate, ctype, cmd\$, func\$, cstatus, srow, scol, erow, ecol, fgc, bgc, fontattr, fontscale, fontface\$, tooltip\$, parentid, winclass, winstyle, winstylex, ctype2**

**Parameters**

| **Option** | **Description** |
|------|------|
| ctlid | standard control identifier. |
| ctext\$ | generally ignored when creating a calendar, unless you specify a _winstyle_ that creates a title bar. _ctext\$ _is however used with the CTLOP\_CHG opcode to set the date or day states. |
| cstate | standard control state options; normally set to MBST\_ENABLE. |
| ctype  | may be set to 0, unless you want to enable a click string, in which case specify the MBF\_KBD flag. |
| cmd\$ | may specify a standard key click string (if MBF\_KBD specified). If so, then clicking on a date will send the click string. Unless the MCS\_DAYSTATES option is specified in _winstyle_, advancing to another month does not trigger the click string. |
| func\$ | ignored |
| cstatus | standard return codes (0=ok) |
| [position](position.md) | See topic of this name. |
| <ignored> | fgc, bgc, fontattr, fontscale, fontface\$ |
| tooltip\$, parentid | work as usual. |
| winclass | must be specified as "ASHMONTHCAL". This replaces the fact that we didn't specify a control type in _ctype_. |
| [winstyle](winstyle.md) | may be used to specify additional style options relating to the window wrapper for the control, as well as options specific to the calendar. See _winstyle_ table for options, values and descriptions. |
| winstylex | may optionally have additional extended window styles: use WS\_EX\_TOPMOST (\&00000008) to force on top (of its siblings) |
| ctype2 | If you plan to modify the color attributes (see Modify section below), you must specify the MBF2\_NOTHEME bit here. |




Once the calendar control is created, there are several additional operations you may want to perform on it, such as highlighting, setting and retrieving dates, modifying colors, etc.  See the sub-topic Operations for details.

**Example**

See the sample program [MONCAL.BP in EXLIB:\[908,42\]](https://bitbucket.org/microsabio/exlib/src/master/908042/moncal.bp) for a simple working example.

**History**

2018 December, A-Shell 6.4.1651:  the MBF2\_NOMOVE flag may now be set when creating the control to stifle the logic which otherwise shifts the control up and/or to the left as needed so that it fits in within the parent window.

2011 April, A-Shell 5.1.1212:  The month calendar control now supports multiple calendars in a single control—i.e. multiple months showing at a time. Because it is difficult to know how big the control coordinates must be in order to display a specific number of calendars, you may now replace the lower right coordinate (erow,ecol) with the number of rows and columns, respectively, of calendars to display, provided that the MBF2\_PIXSIZE flag is specified in the _ctype2_ parameter. For example, srow=1, scol=50, erow=1, ecol=2 will create a control with two calendars side by size, starting at position 1,50. (If the two calendars would extend off the edge of the parent window, the starting coordinates will be adjusted so that the entire calendar fits in the window.)

Note that the day states feature (MCS\_DAYSTATES) is not compatible with multiple calendars. 

The sample program [MONCAL.BP in EXLIB:\[908,42\]](https://bitbucket.org/microsabio/exlib/src/master/908042/moncal.bp) has been enhanced to illustrate the new technique. 

**Subtopics**

- [Position](position.md)

- [Winstyle](winstyle.md)

- [Operations](operationsmoncalctrl.md)