BOOL SetTime( const COleDateTime& timeNew );
BOOL SetTime( const CTime* pTimeNew );
BOOL SetTime( LPSYSTEMTIME pTimeNew = NULL );
Return Value
Nonzero if successful; otherwise 0.
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.
Remarks
This member function implements the behavior of the Win32 message DTM_SETSYSTEMTIME, as described in the Platform 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
void CDatesDlg::OnButton2()
{
// Gain a pointer to the control
// CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetDlgItem(IDC_MONTHCALENDAR1);
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(IDC_DATETIMEPICKER1);
ASSERT(pCtrl != NULL);
// set with a CTime
CTime timeTime(1998, 4, 3, 0, 0, 0);
VERIFY(pCtrl->SetTime(&timeTime));
// set with a COleDateTime object
COleDateTime oletimeTime(1998, 4, 3, 0, 0, 0);
VERIFY(pCtrl->SetTime(oletimeTime));
// set using the SYSTEMTIME
SYSTEMTIME sysTime;
memset(&sysTime, 0, sizeof(sysTime));
sysTime.wYear = 1998;
sysTime.wMonth = 4;
sysTime.wDay = 3;
VERIFY(pCtrl->SetTime(&sysTime));
}
CDateTimeCtrl Overview | Class Members | Hierarchy Chart
See Also CDateTimeCtrl::GetTime