다음을 통해 공유


CMonthCalCtrl::Create

Creates a month calendar control and attaches it to the CMonthCalCtrl object.

virtual BOOL Create(
   DWORD dwStyle,
   const RECT& rect,
   CWnd* pParentWnd,
   UINT nID 
);
virtual BOOL Create(
   DWORD dwStyle,
   const POINT& pt,
   CWnd* pParentWnd,
   UINT nID 
);

Parameters

  • dwStyle
    Specifies the combination of Windows styles applied to the month calendar control. See Month Calendar Control Styles in the Windows SDK for more information about the styles.

  • rect
    A reference to a RECT structure. Contains the position and size of the month calendar control.

  • pt
    A reference to a POINT structure that identifies the location of the month calendar control.

  • pParentWnd
    A pointer to a CWnd object that is the parent window of the month calendar control. It must not be NULL.

  • nID
    Specifies the month calendar control's control ID.

Return Value

Nonzero if initialization was successful; otherwise 0.

Remarks

Create a month calendar control in two steps:

  1. Call CMonthCalCtrl to construct a CMonthCalCtrl object.

  2. Call this member function, which creates a month calendar control and attaches it to the CMonthCalCtrl object.

When you call Create, the common controls are initialized. The version of Create you call determines how it is sized:

  • To have MFC automatically size the control to one month, call the override that uses the pt parameter.

  • To size the control yourself, call the override of this function that uses the rect parameter.

Example

// Given two member objects m_calCtrl1 and m_calCtrl2, we can
// create them in one of two ways.

// Providing a point has the control with its top-left corner
// at that point and sized automatically to show one month
// page.

CPoint pt(10, 10);
VERIFY(m_calCtrl1.Create(WS_TABSTOP | WS_CHILD | WS_VISIBLE | 
   WS_BORDER | MCS_DAYSTATE, pt, this, IDC_MONTHCALCTRL1));

// Providing a rectangle lets us completely control the size.
// The control will paint as many complete month pages in the 
// control's area as possible.

CRect rect(300, 100, 470, 200);
VERIFY(m_calCtrl2.Create(WS_TABSTOP | WS_CHILD | WS_VISIBLE | 
   WS_BORDER | MCS_MULTISELECT, rect, this, IDC_MONTHCALCTRL2));

Requirements

Header: afxdtctl.h

See Also

Reference

CMonthCalCtrl Class

Hierarchy Chart

CMonthCalCtrl::CMonthCalCtrl

Other Resources

CMonthCalCtrl Members