SECCalendar Class

class SECCalendar: public CWnd

SECCalendar implements a standard calendar control which can be used for date entry, as well as date representation. Through the use of member functions, days on the calendar can be highlighted and selected. An SECCalendar instance can be embedded into a dialog, or can be implemented as a popup control through the derived class SECPopupCalendar. SECCalendar can be embedded into a CView as well as a CDialog. Since it is derived from CWnd, it can usually be used anywhere a Cwnd can.

Defined in: Calendar.h

Comments

SECCalendar maintains an internal page date as well as a selected date. The page date corresponds to the day currently being viewed. So, if the page date was specified as May 13th 1993, the month of May would be shown with the current date. If the user advanced the calendar by a month, the current page date would also be advanced internally by one month to June 13th 1993. The only feedback the end user receives is that the month of the current page date is shown in the calendar window.

SECCalendar also maintains a single selected date internally which can be manipulated even if it is not currently being displayed in the current page. In other words, the current page might be June 1993, while the selected date might be all the way back on May 13th 1975. The selected date can be advanced through member functions behind the scenes while the current page remains at June 1993.

The overall behavior of an SECCalendar instance is controlled through a number of behavior and drawing options. The calendar month being drawn consists of carryover days from the previous month as well as days from the next month. For example, if the first day of the displayed month fell on a Tuesday, that would mean that two carryover days from the previous month would be displayed for Sunday and Monday. Similarly, days for the next month are displayed if space permits. Behavior for all displayed days is modified at creation time, or dynamically using the following member functions: SetPrePostDrawMode GetPrePostDrawMode SetDrawMode GetDrawMode SetBehaviorMode GetBehaviorMode

The CALTEST sample in the \SAMPLES\TOOLKIT\STANDARD\CONTROLS\CALENDAR directory demonstrates how SECCalendar and SECPopupCalendar are used.

Class Members

Creation/Initialization

SECCalendar( )

Creates a SECCalendar object.

virtual BOOL Create( DWORD dwStyle, CRect &Rect, CWnd *pWndParent, UINT nID, CCreateContext* pContext = NULL )

Creates a child window and attaches it to the parent window passed in.

Attributes

long GetPrePostDrawMode( void )

Retrieves the current drawing mode of overlapping days.

BOOL SetPrePostDrawMode( long l )

Sets the drawing mode of overlapping days.

long GetBehaviorMode( void )

Retrieves the behavior mode of the calendar.

BOOL SetBehaviorMode( long m )

Sets the behavior mode of the calendar.

long GetDrawMode( void )

Gets the drawing mode of the calendar.

BOOL FAR SetDrawMode( long m )

Sets the drawing mode of the calendar.

BOOL SetPage( const COleDateTime &calendarPage, BOOL bRedraw = FALSE )

Sets the calendar page to be displayed (32-bit only).

const COleDateTime& GetSelectedDateValue( void )

Retrieves the currently selected date (32-bit only)

const CTime& GetSelectedDateValue( void )

Retrieves the currently selected date (16-bit only)

UINT GetAllHighlightedDates( COleDateTime *pDates, UINT nDates )

Retrieves an array of pointers to all highlighted dates. (32-bit only)

UINT GetAllHighlightedDates( CTime *pDates, UINT nDates )

Retrieves an array of pointers to all highlighted dates.

BOOL SetPage( const CTime &calendarPage, BOOL bRedraw = FALSE )

Sets the calendar page to be displayed.

SECDayBox* GetSelectedDate( void )

Retrieves the currently selected date.

UINT GetNumHighlightedDates( void )

Retrieves the number of highlighted dates.

BOOL GetAutosizeFont( void )

Retrieves the status of the automatic size font mode.

void SetAutosizeFont( BOOL bSet )

Sets the status of the automatic size font mode.

BOOL GetAutosizeRect( void )

Retrieves the status of the automatic sizing CRect mode.

void SetAutosizeRect( BOOL bSet )

Sets the status of the automatic sizing CRect mode.

const CRect& GetControlRect( void )

Retrieves the CRect associated with the control.

CRect SetControlRect( CRect &newRect )

Sets a new CRect for the control.

BOOL GetSingleDate( void )

Returns the status of single date selection mode.

BOOL SetSingleDate( BOOL bTurnOn )

Sets the status of single date selection mode.

BOOL GetMonthButtons( void )

Retrieves the active status of the month buttons.

BOOL SetMonthButtons( BOOL bTurnOn )

Sets the active status of the month buttons.

BOOL GetYearButtons( void )

Retrieves the active status of the year buttons.

BOOL SetYearButtons( BOOL bTurnOn )

Sets the active status of the year buttons.

BOOL GetKeyboardControl( void )

Retrieves the active status of keyboard control.

BOOL SetKeyboardControl( BOOL bTurnOn )

Sets the active status of keyboard control.

BOOL GetMonthFrozen( void )

Returns nonzero (true) if the month currently displayed is frozen (can’t be changed).

BOOL SetMonthFrozen( BOOL bMakeFrozen )

Freezes the month currently being displayed by the calendar control (the month can’t be changed).

BOOL GetAutoHide( void )

Retrieves the active status of whether the calendar control is automatically hidden.

BOOL SetAutoHide( BOOL bHideAutomatically )

Sets the active status indicating that the calendar control is automatically hidden.

COLORREF GetTextColor( void )

Retrieves the color of the calendar text.

COLORREF SetTextColor( COLORREF newColor )

Sets the color of the calendar text.

int GetFirstDayOfWeek() const

Retrieves the first day of the week.

void SetFirstDayOfWeek(int nNewFirstDay, BOOL bRedraw = FALSE)

Sets the first day of the week.

void SetCalendarColor(COLORREF newTextClr, COLORREF newDayBarTextClr, COLORREF newTitleTextClr, COLORREF newGrayTextClr)

Sets the color of the calendar text.

void ResetCalendarColor()

Resets the color of the calendar text to default values.

Operations

virtual BOOL AdvanceDay( BOOL bSelectionFollows = TRUE )

Advances the calendar page date by one day.

virtual BOOL RetreatDay( BOOL bSelectionFollows = TRUE )

Decrements the day being viewed by one.

virtual BOOL AdvanceWeek( BOOL bSelectionFollows = TRUE )

Advances the page being viewed by one week.

virtual BOOL RetreatWeek( BOOL bSelectionFollows = TRUE )

Decrements the day being viewed by one week.

virtual BOOL AdvanceMonth( BOOL bSelectionFollows = FALSE )

Advances the page being viewed by one month.

virtual BOOL RetreatMonth( BOOL bSelectionFollows = FALSE )

Decrements the day being viewed by one month.

virtual BOOL AdvanceYear( BOOL bSelectionFollows = FALSE )

Advances the page being viewed by one year.

virtual BOOL RetreatYear( BOOL bSelectionFollows = FALSE )

Decrements the day being viewed by one year.

virtualBOOL HighlightDate( COleDateTime &date, BOOL bSet )

Sets the highlighted state for the date passed in.

virtualBOOL SelectDate( COleDateTime date, BOOL bSet )

Sets the selection state of the date passed in.

virtualBOOL ToggleSelectDate( COleDateTime &date )

Toggles the selection status of the date passed in.

virtualBOOL ToggleHighlightDate( COleDateTime &date )

Toggles the highlighted status of the date passed in.

virtual COLORREF SetHighlightColor( COleDateTime &date, COLORREF newColor )

Sets the highlight color for the date passed in.

virtualBOOL HighlightDate( CTime &date, BOOL bSet )

Sets the highlighted state for the date passed in.

virtualBOOL SelectDate( CTime date, BOOL bSet )

Sets the selection state of the date passed in.

virtualBOOL ToggleSelectDate( CTime &date )

Toggles the selection status of the date passed in.

virtualBOOL ToggleHighlightDate( CTime &date )

Toggles the highlighted status of the date passed in.

virtual COLORREF SetHighlightColor( CTime &date, COLORREF newColor )

Sets the highlight color for the date passed in.

Overridable

virtual void InitColors()

Initializes the colors for the calendar.