CDateTimeCtrl::GetMonthCalCtrl

Retrieves the CMonthCalCtrl object associated with the date and time picker control.

CMonthCalCtrl* GetMonthCalCtrl( ) const;

Return Value

A pointer to a CMonthCalCtrl object, or NULL if unsuccessful or if the window is not visible.

Remarks

Date and time picker controls create a child month calendar control when the user clicks the drop-down arrow. When the CMonthCalCtrl object is no longer needed, it is destroyed, so your application must not rely on storing the object representing the date time picker control's child month calendar.

Example

void CDateTimeDlg::OnDropDownDateTimeCtrl(NMHDR* pNMHDR, LRESULT* pResult)
{
   UNREFERENCED_PARAMETER(pNMHDR);

   // note that GetMonthCalCtrl() will only return a pointer to the 
   // month calendar control while the control actually exists--that is,
   // while it has been dropped-down by the user. Otherwise, the function
   // returns NULL. One appropriate time to get the control is while 
   // handling the DTN_DROPDOWN notification for the date time picker 
   // control.

   // get the control
   CMonthCalCtrl* pMoCalCtrl = m_DateTimeCtrl.GetMonthCalCtrl();
   ASSERT(pMoCalCtrl != NULL);

   // now, pMoCalCtrl is useful...

   *pResult = 0;
}

Requirements

Header: afxdtctl.h

See Also

Concepts

CDateTimeCtrl Class

CDateTimeCtrl Members

Hierarchy Chart