Please enable JavaScript to view this site.

A-Shell Reference

Navigation: Subroutines > AUI > AUI_CONTROL > Control Types

Month Calendar Control

Scroll Prev Top Next More

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

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

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] 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] has been enhanced to illustrate the new technique.

Subtopics

Position

Winstyle

Operations