CDateTimeCtrl 控件关联变量m_timer定义CTime t = CTime::GetCurrentTime(); 获取系统时间定义CTime mtime;m_timer.GetTime(mtime);获取控件时间比较m_timer 跟t 表示的时间:
if(mtime.Format("%H%M%S") == t.Format("%H%M%S")){
   MessageBox(_T("alarm"));
}  
编译通不过,请纠错或有没其它解,目的是定时触发某事件,如设定15点时弹出消息框。

解决方案 »

  1.   

    m_timer.GetWindowText(strTimeStart);
    获得字符串后,再比较字符串
      

  2.   

    CTime类重载了operator == 操作符bool operator ==(
       CTime time 
    ) const throw( );
    bool operator !=(
       CTime time 
    ) const throw( );
    bool operator <(
       CTime time 
    ) const throw( );
    bool operator >(
       CTime time 
    ) const throw( );
    bool operator <=(
       CTime time 
    ) const throw( );
    bool operator >=(
       CTime time 
    ) const throw( );
      

  3.   

    还是楼上的MVP同志古道热肠,轻轻的问一下MVP同志:你挂那么多的勋章,有什么好处的?难道只是为了好看?
      

  4.   

    你这个时间控件关联的变量m_timer是什么类型哦?  要是CTime类型直接就m_timer.Format("%H%M%S");还搞什么CTime mtime; m_timer.GetTime(mtime); 这个肯定有问题啊. 
      

  5.   

    UpdateData(TRUE);刷新一下你定的时间,然后直接比较两个时间:
    CDateTimeCtrl控件关联变量CTime m_timer;
    CTime t = CTime::GetCurrentTime();
    if(m_timer.Format("%H%M%S") == t.Format("%H%M%S"))
    {
      MessageBox(_T("alarm"));
    }  
      

  6.   

    直接比就是了
    CTime mTime,currentTime;; m_time_end.GetTime(mTime);   //m_time_end为CDateTimeCtrl控件变量 currentTime= currentTime.GetCurrentTime();
    if (mTime == currentTime)
    {
    AfxMessageBox(_T("=="));
    }
    else
    {
    AfxMessageBox(_T("!="));
    }
      

  7.   

    上面第一句多了个分号,
    CTime mTime,currentTime;
        m_time_end.GetTime(mTime);   //m_time_end为CDateTimeCtrl控件变量    currentTime= currentTime.GetCurrentTime();
        if (mTime == currentTime)
        {
            AfxMessageBox(_T("=="));
        }
        else
        {
            AfxMessageBox(_T("!="));
        }
      

  8.   

    将时间转换成需要的字符串格式,再比较字符串是否相等。从控件上取时间时,记得要先UpdateData();你都说了编译通不过,为何不给出错误提示呢?让人瞎猜,浪费时间。