CDateTimeCtrl 设定为“ShowNone” 为 True
2.Format 初始化
CDateTimeCtrl m_Date1;
m_Date1.SetFormat(_T("yyyy'- 'MM'- 'dd"));
3.Format初始化选择确认框为空
CDateTimeCtrl m_Date1;
::SendMessage( this->m_Date1.m_hWnd,(UINT)DTM_SETSYSTEMTIME,GDT_NONE, NULL);
4.Format初始化选择确认框变化是产生的动作
voidPageDialog4::OnDtnDatetimechangeDatetimepicker1(NMHDR *pNMHDR,LRESULT *pResult)
{
LPNMDATETIMECHANGE pDTChange =reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
if(pDTChange->dwFlags == GDT_NONE)
{
this->m_Date2.EnableWindow(FALSE);
}
else if (pDTChange->dwFlags == GDT_VALID)
{
if( this->m_Date2.IsWindowEnabled() == FALSE)
{
this->m_Date2.EnableWindow(TRUE);
CTime theTime = CTime::GetCurrentTime();
this->m_Date1.SetTime(&theTime);
this->m_Date2.SetTime(&theTime);
}
}
*pResult= 0;
}
5.获取时间
CTimetimeTime;
CString szDate;
CDateTimeCtrl* pCtrl =&this->m_Date1;
DWORD dwResult =pCtrl->GetTime(timeTime);
if (dwResult == GDT_VALID)
{
szDate = timeTime.Format(TEXT("%Y/%m/%d"));
}
获取时间的第二种方法:
6.根据Format格式设定时间
CTime theTime = CTime::GetCurrentTime();
this->m_Date1.SetTime(&theTime);