MFC在static text中动态显示系统时间

来源:互联网 发布:c语言新手编写小游戏 编辑:程序博客网 时间:2024/05/16 04:49

1.添加static text ,ID为IDC_ShowTime

2,在OnInitDialog()中


       SetTimer(1,1000,NULL);         //启动定时器

3.添加WM_TIMER消息处理函数,ontimer中添加如下代码:
       CString strTime;
       CTime tm;
       tm=CTime::GetCurrentTime();        
        strTime=tm.Format("%Y-%m-%d %H:%M:%S");
       SetDlgItemText(IDC_ShowTime,strTime);        //显示系统时间
0 0
原创粉丝点击