我定义了一个VIEW类定义了一个INT m_time
定时器使用次数
int temp;
if (m_str.GetLength()>=80)
{
m_time = SetTimer(1,1500,NULL);
}
else
{
temp =0;
}void CToolView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
temp--;
TCHAR STR[256];
itoa(temp,STR,10);
// AfxMessageBox(STR);
if (temp==0)
{
//这里使用对吗?怎么关不了呢还是一直在调用下面的FUN函数
KillTimer(m_time);
}
else
Fun(m_str);
CHtmlView::OnTimer(nIDEvent);
}
定时器使用次数
int temp;
if (m_str.GetLength()>=80)
{
m_time = SetTimer(1,1500,NULL);
}
else
{
temp =0;
}void CToolView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
temp--;
TCHAR STR[256];
itoa(temp,STR,10);
// AfxMessageBox(STR);
if (temp==0)
{
//这里使用对吗?怎么关不了呢还是一直在调用下面的FUN函数
KillTimer(m_time);
}
else
Fun(m_str);
CHtmlView::OnTimer(nIDEvent);
}
KillTimer(1);
KillTimer(1); 就可以了
if (temp==0)
{
//这里使用对吗?怎么关不了呢还是一直在调用下面的FUN函数
KillTimer(m_time);
}
else
Fun(m_str);
你这个是什么逻辑。
it is so cool
感谢各位结贴
KillTimer(1); 就可以了
楼主这里没错。
Return ValueThe timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.
temp 是计数用的 就是限定定时器使用的次数,我希望它执行10次 temp 赋值为10 前面有个temp--;不知道有什么问题,全是自学没有什么开发经验
KillTimer(1); 就可以了 我这里m_time的值的确是1,但是KillTimer(m_time); 定时器不停的执行
KillTimer(1);就可以了,不知道为什么,唉
不是吧LZ的代码没有问题,只是定时器ONTIMER里是不是应该判断下nIDEvent,不知你共SET了几个TIMER