Chinaunix首页 | 论坛 | 博客
  • 博客访问: 672372
  • 博文数量: 134
  • 博客积分: 3158
  • 博客等级: 中校
  • 技术积分: 1617
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-30 22:36
文章分类

全部博文(134)

文章存档

2012年(2)

2011年(28)

2010年(68)

2009年(35)

2008年(1)

我的朋友

分类: WINDOWS

2010-09-25 15:22:01

 

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 object containing the to which the control will be set.

pTimeNew

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

Remarks

This member function implements the behavior of the Win32 message , 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));
}
阅读(1635) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~