zoukankan      html  css  js  c++  java
  • 2、创建MFC应用程序——基于对话框,时间计时器

    使用计时器更新MFC界面时间,频率1s。

    文件——新建项目——MFC应用程序,下一步,选择基于对话框,其他默认,完成。

    双击窗体(或者鼠标右键)进入类向导,自动创建Ontimer()函数

    void CMFCApplication8Dlg::OnTimer(UINT_PTR nIDEvent)
    {
        // TODO:  在此添加消息处理程序代码和/或调用默认值
        CTime time = CTime::GetCurrentTime();//获取当前时间
        CString str;
        str.Format(_T("%d年%2d月%2d日 %2d:%2d:%2d"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
        SetDlgItemText(IDC_EDIT1, str);//在文本框中显示str结果
    
        CDialogEx::OnTimer(nIDEvent);
    }

    // CMFCApplication8Dlg 消息处理程序

    BOOL CMFCApplication8Dlg::OnInitDialog()中添加

    SetTimer(1, 1000, NULL);//计时器1,1000ms触发一次OnTimer()函数
  • 相关阅读:
    [BZOJ3257]树的难题
    [BZOJ4987]Tree
    [NOI2015][洛谷P2150]寿司晚宴
    P2221 [HAOI2012]高速公路
    BUG全集(我遇到的)
    NOIP2018游记
    BZOJ1103
    Google Chrome 优化
    特殊空格
    Ant Design Vue 使用
  • 原文地址:https://www.cnblogs.com/xixixing/p/11872296.html
Copyright © 2011-2022 走看看