求教data time picker 我使用两个data time picker控件,其中一个命名为"起始时间",另一个是"截止时间"初始化时我令"截止时间"是当前时间,我想问问各位高手,怎样使"起始时间"与"截止时间"是一个月呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你给这两个控件设两个关联的变量,然后定义一个Timespan 类型的变量设定为1个月。然后加让后面的结束时间等于开始时间加上Timespan就是两个时间间隔1个月。 CTimeSpan -> CTimeCOleTimeSpan -> COleDateTimetm2 = tm1 + timeSpan(1个月) COleDateTime t1, t2; t2 = COleDateTime::GetCurrentTime(); t1 = t2; switch(t1.GetMonth()) { case 1: //一月份 t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay()); break; case 3: //三月份 if(t1.GetDay() >= 29) { if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0) || t1.GetYear() % 400 == 0) //闰年 t1.SetDate(t1.GetYear(), 2, 29); else t1.SetDate(t1.GetYear(), 2, 28); } els写的有点复杂了。 COleDateTime t1, t2; t2 = COleDateTime::GetCurrentTime(); t1 = t2; switch(t1.GetMonth()) { case 1: //一月份 t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay()); break; case 3: //三月份 if(t1.GetDay() >= 29) { if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0) || t1.GetYear() % 400 == 0) //闰年 t1.SetDate(t1.GetYear(), 2, 29); else t1.SetDate(t1.GetYear(), 2, 28); } els写的有点复杂了。 COleDateTime t1, t2; t2 = COleDateTime::GetCurrentTime(); t1 = t2; switch(t1.GetMonth()) { case 1: //一月份 t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay()); break; case 3: //三月份 if(t1.GetDay() >= 29) { if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0) || t1.GetYear() % 400 == 0) //闰年 t1.SetDate(t1.GetYear(), 2, 29); else t1.SetDate(t1.GetYear(), 2, 28); } else t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay()); break; case 5: case 7: case 10: case 12: //前一个月是小月 if(t1.GetDay() == 31) t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, 30); else t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay()); break; default: //其它月份 t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay()); } CString str; str = t1.Format("%Y-%m-%d %H:%M:%S"); 我想问个重绘的问题 vc++ DBgrid的自动更新 刚开始学习vc++,看什么书好呢。 如何得到IID_IHTMLDocument2的指针呢? vc中EDIT控件的字体颜色怎么设置??? 我按部就班自定义的消息为什么不行?和以前的没什么区别的,以前在单文档,现在在多文档而已啊。 在win2k系统中如何直接进入操作系统(不出现密码提示框无须输入密码) 寻高手兼职 那位高手能给小弟解释一下(vc--数据库)? 请教:怎样用CEdit的对象create一个俩行的edit对话框,谢谢!! 在线程函数中获取主窗口DC的问题 请高手帮忙把我的程序OpenMP并行化
t2 = COleDateTime::GetCurrentTime();
t1 = t2;
switch(t1.GetMonth())
{
case 1: //一月份
t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay());
break;
case 3: //三月份
if(t1.GetDay() >= 29)
{
if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0)
|| t1.GetYear() % 400 == 0) //闰年
t1.SetDate(t1.GetYear(), 2, 29);
else
t1.SetDate(t1.GetYear(), 2, 28);
}
els
写的有点复杂了。
t2 = COleDateTime::GetCurrentTime();
t1 = t2;
switch(t1.GetMonth())
{
case 1: //一月份
t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay());
break;
case 3: //三月份
if(t1.GetDay() >= 29)
{
if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0)
|| t1.GetYear() % 400 == 0) //闰年
t1.SetDate(t1.GetYear(), 2, 29);
else
t1.SetDate(t1.GetYear(), 2, 28);
}
els写的有点复杂了。
t2 = COleDateTime::GetCurrentTime();
t1 = t2;
switch(t1.GetMonth())
{
case 1: //一月份
t1.SetDate(t1.GetYear() - 1, 12, t1.GetDay());
break;
case 3: //三月份
if(t1.GetDay() >= 29)
{
if((t1.GetYear() % 4 == 0 && t1.GetYear() % 100 != 0)
|| t1.GetYear() % 400 == 0) //闰年
t1.SetDate(t1.GetYear(), 2, 29);
else
t1.SetDate(t1.GetYear(), 2, 28);
}
else
t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay());
break;
case 5:
case 7:
case 10:
case 12: //前一个月是小月
if(t1.GetDay() == 31)
t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, 30);
else
t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay());
break;
default: //其它月份
t1.SetDate(t1.GetYear(), t1.GetMonth() - 1, t1.GetDay());
}
CString str;
str = t1.Format("%Y-%m-%d %H:%M:%S");