//初始化
BOOL CDataControlDlg::OnInitDialog()
{
//初始化日期控件
CDateTimeCtrl *pDateTiemCtrl = (CDateTimeCtrl*)GetDlgItem(IDC_DATETIMEPICKER); //指针指向日期控件
SYSTEMTIME SysTime; //系统时间
memset(&SysTime, 0, sizeof(SysTime));
SysTime.wYear = 2016;
SysTime.wMonth = 11;
SysTime.wDay = 13;
SysTime.wHour = 8;
SysTime.wMinute = 35;
pDateTiemCtrl->SetTime(&SysTime);
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
//静态文本框(获取时间)
void CDataControlDlg::OnStnClickedStaticGettime()
{
// TODO: 在此添加控件通知处理程序代码
CTime timeDate;
CString strTime;
m_DataTimeCtrl.GetTime(timeDate);
strTime.Format(_T("%d年%d月%d日%d时%d分"), timeDate.GetYear(), timeDate.GetMonth(), timeDate.GetDay(),timeDate.GetHour(),timeDate.GetMinute());
MessageBox(strTime);
m_StrDateTime = strTime; //编辑框绑定变量
UpdateData(FALSE); //更新编辑框控件内容
}
//静态文本框(重置时间)
void CDataControlDlg::OnStnClickedStaticResettime()
{
// TODO: 在此添加控件通知处理程序代码
CTime cTime(1999, 9, 9, 0, 0, 0, 0);
m_CmothCalCtrl.SetCurSel(cTime);
}