关于由OnTimer()完成的活动的问题 [英] A Question about an activity done by OnTimer()

查看:71
本文介绍了关于由OnTimer()完成的活动的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我对Visual C ++ 6.0中的OnTimer()函数有疑问.我的程序包含2个类-假设A类和B类. A类叫我一个屏幕,用户必须选择一个选项(例如开始"之类的东西).当用户单击START时,它将称为B类.我正在使用DoModal()进行此操作.
在类B中,我使用OnTimer()制作运动对象(例如椭圆).如果我按Esc键,则称我为A类.如果我多次执行此过程(从A类到B以及从B类到A),我会注意到在B类中,运动对象开始滞后(下降速度降低-错误或其他原因).如果有的话,我正在征求您的意见和解决方案.在此先感谢!

Hello, i have a question about OnTimer() function in Visual C++ 6.0. My program contais 2 classes - let''s say a class A and a class B . Class A calls me a screen and the user must choose an option(e.g. Start or something). When the user clicks on START it calls me class B. I''m doing that using DoModal().
In class B i''m using OnTimer() to make moving objects(e.g. ellipses). If i press Esc key it calls me A class back. If i do this process several times(from A class to B and from B to A) i notice that in B class the moving objects start to lag(the falling speed decreases - bug or something). I''m asking for your opinion and solution if you have that. Thanks in advance!

推荐答案

谁和哪里
会启动并杀死计时器吗? :)
Who and where
does start and kill the timer ? :)


您的技术只是一部惊悚片... :)

您可以开始分析
试图记住并杀死最后一个计时器
在B :: OnDestroy()函数中...

其次,
认为WM_TIMER的处理
仅在主线程中占位,
因此您可以发挥相同的理论效果
也有一个单独的计时器...:)
Your technique is just a thriller... :)

You can begin the analysis
trying to remember and kill the last timer
in the B::OnDestroy() function...

Secondly,
think that the handling of WM_TIMER
has its place in the main thread only,
so you could take the same theoretic effect
with a singly timer too... :)


就像我说过我有很多下降的东西,而且我使用了不同的计时器一样.第一个计时器:SetTimer(1,100,NULL)在OnInitDialog()中启动;
然后在OnTimer中进行检查并取消计时器并设置一个新计时器.我循环执行

for(int i = 1; i< = 100; i ++)
{
if(y [i]> 500)
{
KillTimer(i);
SetTimer(i + 1,100,NULL);
}

}
Like i said i have a lot of falling stuffs and i''m using different timers. The first timer: SetTimer(1, 100, NULL) starts in OnInitDialog();
Then in OnTimer I make a check and kill the timer and set a new one. I do it in a loop

for(int i=1; i<=100; i++)
{
if(y[i]>500)
{
KillTimer(i);
SetTimer(i+1, 100, NULL);
}

}


这篇关于关于由OnTimer()完成的活动的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆