Calendar Control
SECCalendar implements a standard calendar control for date entry and date representation. You can invoke methods to highlight and select days on the calendar. You can embed an SECCalendar instance into a dialog or implement it as a pop-up control through the derived class SECPopupCalendar. SECPopupCalendar allows the user to view the calendar control as a drop-down window, which saves screen space.
The calendar class hierarchy is as follows:
Figure 17 – Objective Toolkit Calendar Class Hierarchy
Figure 18 – SECCalendar Display
To incorporate the SECCalendar class into your code
1. Create an instance of SECCalendar or SECPopupCalendar.
2. Call the SetPage() method to display the appropriate month for a given date. For 32-bit versions of Objective Toolkit, pass in either a COleDateTime reference or a CTime reference. For example:
COleDateTime date = COleDateTime::GetCurrentTime();
// bRedraw MUST be FALSE when presetting a page.
m_theCalendar.SetPage(date, FALSE);
NOTE >> The CTime class encapsulates the run-time time_t data type. it represents absolute time values only in the range January 1, 1970 to January 18, 2038, inclusive.
3. Call the SetBehaviorMode() and SetDrawMode() methods. For example:
NOTE >> You can override these methods to customize the behavior mode and drawing mode.
4. Call the Create() method. For example:
m_theCalendar.Create( WS_VISIBLE|WS_BORDER,
rect, this, IDC_CALENDAR_FRAME );
NOTE >> If you are using SECPopupCalendar, WS_POPUP is a valid window style.
SECCalendar Key Methods
*SetDrawMode(). Sets the drawing mode of the calendar with the flags specified in the following table.
Table 6 – Drawing Mode Flags for SECCalendar 
Draw Flag
Uses full month names.
Uses full day names.
*SetBehaviorMode(). Sets the behavior mode of the calendar with the flags specified in the following table:
Table 7 – Behavior Mode Flags for SECCalendar 
Behavior Flag
Automatically scales the font to fit the current size of the control.
Automatically scales the calendar’s bounding rectangle to fit the parent window.
Allows the user to select a single date.
Displays the buttons to scroll months.
Displays the buttons to scroll years.
Hides the calendar automatically when the user is done.
Allows navigation of the calendar with the keyboard.
Freezes the currently displayed month.
*SetPage(). Sets the displayed calendar page based on the CTime or COleDateTime parameter passed in.
*HighlightDate(). Sets the highlighted mode of the specified date. Multiple dates can be highlighted at one time.
*SelectDate(). Selects the date based on the CTime or COleDateTime parameter passed in. The user can only select one date at any given time.
*ToggleSelectDate(). Toggles the selected mode of the specified date.
*ToggleHighlightDate(). Toggles the highlighted mode of the specified date. Multiple dates can be highlighted at one time.
*AdvanceDay(), AdvanceWeek(), AdvanceMonth(), AdvanceYear(). Advances the calendar by the given amount.
*RetreatDay(), RetreatWeek(), RetreatMonth(), RetreatYear(). Retreats the calendar by the given amount.
Customizing SECCalendar
Most of the SECCalendar operation methods (AdvanceDay(), AdvanceWeek(), AdvanceMonth(), and more) are virtual functions that you can override to add custom behavior to a derived class. In addition, you can override the InitColors() method to specify colors for the various parts of the calendar. The default implementation initializes the colors based on the current system colors.
SECCalendar Sample
The use of SECCalendar and SECPopupCalendar is demonstrated in the caltest sample in the Samples\Toolkit\MFC\Controls\calendar directory. This sample is not shipped with the product. For information on how to obtain this sample, see “Location of Sample Code” in the Getting Started part.