Article ID: 200054 - View products that this article applies to.
This article was previously published under Q200054
This article has been archived. It is offered "as is" and will no longer be updated.
If you call the SetTimer function to send periodic WM_TIMER messages to a list control, you may find that the WM_TIMER message handler (the OnTimer function) for a list control is called only twice.
The WM_TIMER handler in the list control calls the KillTimer function.
If you define the timer ID in the SetTimer call, do not call the default handler for WM_TIMER.
The list control uses the timer for editing labels, and for scrolling. When you handle the timer message, if the timer ID is your own timer, don't call the default handler (CListCtrl::OnTimer).
In the sample code below, without the if clause in the CMyListCtrl::OnTimer function, the default WM_TIMER handler is always called, which destroys both the control's timer and your own timer. As a result, you should see a trace statement for each timer.
Article ID: 200054 - Last Review: February 23, 2014 - Revision: 2.1