다음을 통해 공유


CDateTimeCtrl::SetTime

Sets the time in a date and time picker control.

BOOL SetTime(
   const COleDateTime& timeNew 
);
BOOL SetTime(
   const CTime* pTimeNew 
);
BOOL SetTime(
   LPSYSTEMTIME pTimeNew = NULL 
);

Parameters

  • timeNew
    A reference to a COleDateTime object containing the to which the control will be set.

  • pTimeNew
    In the second version above, a pointer to a CTime object containing the time to which the control will be set. In the third version above, a pointer to a SYSTEMTIME structure containing the time to which the control will be set.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function implements the behavior of the Win32 message DTM_SETSYSTEMTIME, as described in the Windows SDK. In the MFC implementation of SetTime, you can use the COleDateTime or CTime classes, or you can use a SYSTEMTIME structure, to set the time information.

Example

// set with a CTime
CTime timeTime(1998, 4, 3, 0, 0, 0);
VERIFY(m_DateTimeCtrl.SetTime(&timeTime));

// set with a COleDateTime object
COleDateTime oletimeTime(1998, 4, 3, 0, 0, 0);
VERIFY(m_DateTimeCtrl.SetTime(oletimeTime));

// set using the SYSTEMTIME
SYSTEMTIME sysTime;
memset(&sysTime, 0, sizeof(sysTime));
sysTime.wYear = 1998;
sysTime.wMonth = 4;
sysTime.wDay = 3;
VERIFY(m_DateTimeCtrl.SetTime(&sysTime));

Requirements

Header: afxdtctl.h

See Also

Concepts

CDateTimeCtrl Class

CDateTimeCtrl Members

Hierarchy Chart

CDateTimeCtrl::GetTime