VS2010用MFC显示系统当前时间
来源:互联网 发布:java.util.hashmap 编辑:程序博客网 时间:2024/06/07 02:55
1.在对话框标题栏显示当前时间
1.1.在对话框类里添加如下成员
private:
CTime beginTime;
1.2在初始化对话框函数OnInitDialog()里添加如下代码:
beginTime = CTime::GetCurrentTime();
SetTimer(1,1000,NULL);
1.3通过类向导建立消息事件WM_TIMER,并在OnTimer函数中添加如下代码:
CTime cTime = CTime::GetCurrentTime();
CString strTime; //字符串格式化时间
strTime = cTime.Format("现在是%Y年%m月%d日 %X");
SetWindowText(strTime);
2.在对话框的编辑框中显示时间
2.1.对话框中编辑框ID为IDC_EDIT,关联变量为CString的m_time
2.2.将void CCtlEditDlg::DoDataExchange(CDataExchange* pDX)中的
DDX_Control(pDX, IDC_EDIT1, m_time);改为DDX_DateTimeCtrl(pDX, IDC_EDIT1, m_time);
2.3在OnInitDialog()中添加代码:
CString strTime;
CTime tm;
tm=CTime::GetCurrentTime();
strTime=tm.Format("%y年%m月%d日 %X");
SetDlgItemText(IDC_EDIT1,strTime);
SetTimer(1,1000,NULL);
2.4. 给对话框添加WM_TIMER消息处理函数,添加如下代码:
CString strTime;
CTime tm;
tm=CTime::GetCurrentTime();
strTime=tm.Format("%Y-%m-%d %H:%M:%S");
SetDlgItemText(IDC_EDIT1,strTime);
- VS2010用MFC显示系统当前时间
- VS2010用MFC显示系统当前时间
- VS2010/MFC 获取系统当前时间
- MFC 对话框中显示系统当前时间
- mfc 单文档显示当前系统时间
- MFC 对话框中显示系统当前时间
- 显示当前系统时间
- MFC 显示系统时间
- MFC获取系统当前时间
- MFC获取系统当前时间
- MFC获取系统当前时间
- MFC获取当前系统时间
- MFC获取系统当前时间
- MFC获取系统当前时间
- 【MFC】获取系统当前时间
- 【MFC】MFC获取系统当前时间
- javascript 显示当前系统时间
- python显示当前系统时间
- java 工厂方法模式
- 基于安卓的小型计算器
- 在main()之前,IAR都做了啥?
- java 简单工厂模式
- 分析Java类加载全过程
- VS2010用MFC显示系统当前时间
- 字典树
- iOS 5 Tech Talk: Michael Jurewitz on Performance Measurement
- Javascript实现弹出菜单,弹出窗口
- VC++2012编程演练数据结构《36》磁盘文件进行排序
- 算符优先算法(FIRSTVT集,LASTVT集,判读是否是算符优先文法,算符优先矩阵,句子分析)
- 用C语言实现常见的几个排序方法
- Popular Study cards for Secondaries, Harvard
- KMP算法