mfc 的编辑框中怎么显示系统的当前时间啊

琴乐音 2007-01-24 09:54:19
如题!!!
CTime theTime;
theTime = CTime::GetCurrentTime();
取得时间, 但是怎么显示出来呢
...全文
859 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xixuanfong 2007-02-01
  • 打赏
  • 举报
回复
楼上正解很多,不多罗嗦了哦,顶一下,呵呵
iProgramer 2007-02-01
  • 打赏
  • 举报
回复
来晚了
haoguozhong 2007-02-01
  • 打赏
  • 举报
回复
来晚了
yixiao386 2007-01-30
  • 打赏
  • 举报
回复
来晚了 没的说了 呵呵
lid0770 2007-01-30
  • 打赏
  • 举报
回复

CTime tm = CTime::GetCurrentTime();
CString sTime = tm.Format("%X");
cEdit.SetWindowText(sTime);
nadine 2007-01-30
  • 打赏
  • 举报
回复
dazedase说的对啊
miaoshengwu 2007-01-27
  • 打赏
  • 举报
回复
GetDlgItem(IDC_EDIT1)->SetWindowText("时间字符串");
jerry4711 2007-01-27
  • 打赏
  • 举报
回复
在OnTimer函数中写:
CTime tCurrentTime; //当前时间变量
int ih,im,is; //记录小时、分钟、秒的整型变量

tCurrentTime=CTime::GetCurrentTime(); //取得当前时间
ih=tCurrentTime.GetHour(); //取得当前时间小时数
im=tCurrentTime.GetMinute(); //取得当前时间分钟数
is=tCurrentTime.GetSecond(); //取得当前时间秒数
m_strCurr.Format("现在时间是%d点%d分%d秒",ih,im,is); //格式化字符串
UpdateData(FALSE);
dazedase 2007-01-26
  • 打赏
  • 举报
回复
最简单的方法:

CString m_strTime ;
CTime theTime;
theTime = CTime::GetCurrentTime();
m_strTime =theTime.Format("%Y/%m/%d %H:%M:%S");//Format注意大小写!!

再将m_strTime 显示到编辑框即可
东文-桑晨 2007-01-24
  • 打赏
  • 举报
回复
CTime theTime;
theTime = CTime::GetCurrentTime();
CString str;
str.Format("%d-%d-%d %d:%d:%d",
theTime.GetYear(), theTime.GetMonth(), theTime.GetDay(),
theTime.GetHour(), theTime.GetMinute(), theTime.GetSecond());
//年月日时分秒的顺序随你排列,就是说theTime.GetYear(), theTime.GetMonth(),
//theTime.GetDay(), theTime.GetHour(), theTime.GetMinute(), theTime.GetSecond());
//可以任意调换

SetDlgItemText(IDC_EDIT1,str);//IDC_EDIT1是你的编辑框空件的ID
pyrophile 2007-01-24
  • 打赏
  • 举报
回复
还要调用UpdateData(false);函数
niying 2007-01-24
  • 打赏
  • 举报
回复
if m_strTime = 编辑框
{

m_strTime.Format("%04d-%02d-%02d %02d:%02d:%02d", theTime.GetYear(),theTime.GetMonth(),...);

UpdateData(false);
}
王国凡 2007-01-24
  • 打赏
  • 举报
回复
再调用 SetDlgItemText 把 str 设置到编译框中.
王国凡 2007-01-24
  • 打赏
  • 举报
回复
CTime theTime;
theTime = CTime::GetCurrentTime();
CString str;
str.Format("%d-%d-%d %d:%d:%d",
theTime.GetYear(), theTime.GetMonth(), theTime.GetDay(),
theTime.GetHour(), theTime.GetMinute(), theTime.GetSecond());

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧