CDateTimeCtrl控件
发布网友
发布时间:2022-05-02 15:38
我来回答
共2个回答
热心网友
时间:2022-06-20 16:59
// 首先必须保证你的strTime是 unicode 宽字符的,如果不是转换为宽字符。
// 使用OLE函数。
DATE dtResult;
HRESULT hr= VarDateFromStr( strTime, GetSystemDefaultLCID(), 0, &dtResult);
// m_theDateTimePicker;
m_theDateTimePicker.SetTime( COleDateTime(dtResult) );
热心网友
时间:2022-06-20 17:00
SetTime Sets the time in a date and time picker control.
MSDN中可以查到
CDateTimeCtrl::SetTime
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 aSYSTEMTIME structure containing the time to which the control will be set.
Remarks
This member function implements the behavior of the Win32 messageDTM_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.