|

Calendar control

This is a simple calendar control, which displays a month-view and lists
appointments for each day. When the mouse hovers over a day-cell, a ToolTip
displays a detailed description of that day's appointments.
To see it used in a more real application, try to look at this PIM sample.
You would usually use this control in a WTL view, so use the standard WTL AppWizard
to generate a project and derive from CCalendarImpl instead of
CWindowImpl or whatever. Finally remember to chain the
control in the view's message map:
CHAIN_MSG_MAP( CCalendarImpl<CMyCalendarView> )
The control is also able to work as a subclassed STATIC control on a dialog.
Weeknumbers are printed on the left side of the control.
It turns out that weeknumber is one of those topics that quickly gets nasty
and religous, because everyone has their own way of calculating weeknumbers.
Luckily I stumbled over an implementation of the ISO standard, so it should
be safe (I wish).
Custom drawing is supported by reflecting on the WM_DRAWITEM notification
in the owner window. The owner can custom draw each calendar cell.
Oh, and the control uses the MonthCalendar control for its month
selector component, so remember to AtlInitCommonControls() with
the ICC_DATE_CLASSES flag.
Interface
| | Name | Description |
 | GetCurSel | Retrieves the currently selected month. |
 | SetCurSel | Sets the calendar month to display. |
 | SetCalendarStyle | Changes the extended control styles. |
 | DeleteAllItems | Removes all appointments from the view. |
 | AddItem | Adds a new appointment. |
 | GetItemCount | Returns the present number of appointments. |
 | GetItem | Returns an appointment. |
 | HitTest | Tests which day is located at the coordinates. |
 | GetCalendarRange | Retrieves the range of days currently displayed in the entire calendar-view. |
 | SetFont | Sets a new font. |
 | SetTitle | Sets a new title. |
 | SetBkColor | Sets the background color of the cells. |
 | SetSelColor | Sets the color of the selected cell. |
 | InvalidateCell | Repaint a particular day-cell. |
Source Code Dependencies
Microsoft Visual C++ 6.0
Microsoft WTL 3.1 Library
See Also
The Calendar and DayPlanner controls in action.
Download Files
Written by Bjarke Viksoe. Article submitted 2/16/2003.
To the top
|