Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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!
Posted

Who and where
does start and kill the timer ? :)
 
Share this answer
 
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... :)
 
Share this answer
 
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);
}

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900