다음을 통해 공유


CMonthCalCtrl::GetToday

Retrieves the date information for the date specified as "today" for a month calendar control.

BOOL GetToday( 
   COleDateTime& refDateTime  
) const;
BOOL GetToday( 
   COleDateTime& refDateTime  
) const;
BOOL GetToday(
   LPSYSTEMTIME pDateTime 
) const;

Parameters

  • refDateTime
    A reference to a COleDateTime or CTime object indicating the current day.

  • pDateTime
    A pointer to a SYSTEMTIME structure that will receive the date information. This parameter must be a valid address and cannot be NULL.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function implements the behavior of the Win32 message MCM_GETTODAY, as described in the Windows SDK. In MFC's implementation of GetToday, you can specify a COleDateTime usage, a CTime usage, or a SYSTEMTIME structure usage.

Example

void CMonthCalDlg::OnBnClickedGettodaybutton()
{
   COleDateTime timeToday;
   if (m_calCtrl1.GetToday(timeToday))
   {
      // Format the date information from the value we received
      // and post a message box about it.
      CString str = timeToday.Format(VAR_DATEVALUEONLY);
      AfxMessageBox(str);

      // Set the control's "today" indicator to be five
      // days previous.
      timeToday -= 5;
      m_calCtrl1.SetToday(timeToday);
   }
   else
   {
      // Something is wrong!
      ASSERT(FALSE);
   }
}

Requirements

Header: afxdtctl.h

See Also

Reference

CMonthCalCtrl Class

Hierarchy Chart

CMonthCalCtrl::SetToday

Other Resources

CMonthCalCtrl Members