Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a CDocument Class , I must call a timer and I call it with CView class..my code:
void CScaricoView::OnTimer(UINT nIDEvent)  // called every uElapse milliseconds
{
	// do something, but quickly
	GetDocument()->Prova();
	CScaricoView::OnTimer(nIDEvent);
}





but U have this error in CDocument and I don't know why..

void CScaricoDoc::Prova()
{
	int pp = 5;
}


What I have tried:

I tried to remove timer and software works
Posted
Updated 29-May-23 19:15pm
v3

Quote:
void CScaricoView::OnTimer(UINT nIDEvent) // called every uElapse milliseconds
{
// do something, but quickly
GetDocument()->Prova();
CScaricoView::OnTimer(nIDEvent); <-- PROBLEM HERE
}


This is a recursive call (without stop condition).

The timer handler is already invoked repeatedly, just remove the marked line.
 
Share this answer
 
Mr. Pallini is correct. I will repeat myself from your previous question, your OnTimer method should look something like this :
C++
void CScaricoView::OnTimer( UINT_PTR timertId )
{
   if( timerId == MyTimerId )    // handle only YOUR timer event, not all of them
   {
      // handle timer event
   }
   __super::OnTimer( eventId );  // let base class have its shot at it
}
 
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