Reputation: 537
I have an MFC Application where I'm using the ON_WM_TIMER.
The first 1-2 minutes, I fire up the timer with
m_nIDEvent = SetTimer( 234, 500, NULL );
This is working perfectly, but after 2-3 minutes of running the application, I'm getting another event that I have no idea where is it coming from every 100ms or so.
So, I have void SomeClass::OnTimer(UINT event) { char str[100]; sprintf_s(str, "event = %d\n", event); }
At first it only prints out the event #234, but after 2-3 minutes it starts displaying some events from 430-432. Any ideas?
I tried putting a breakpoint at afxwin2.inl ( where SetTimer is is defined ) and with the event I put it stops there as intended, but not with the other random event.
Any ideas?
Thanks!
Upvotes: 0
Views: 531
Reputation: 308432
This is the nature of the Windows timer. All timer events get handled by the single message WM_TIMER, and your OnTimer
function should check for the specific events it can handle. Some Windows components can generate their own timer requests, and those won't go through the MFC SetTimer function to trigger your breakpoint.
Upvotes: 1