Click to See Complete Forum and Search --> : CListView and WM_TIMER


cdehaven
June 3rd, 1999, 03:49 PM
I'm having a problem getting a WM_TIMER message to work with a CListView object. If I derive my object from a CView all is fine. As soon as I switch over to the CListView, the timer hits the first couple of times, then never again. The odd thing is that if I just click my mouse in one of the cells in the CListView's ListViewCtrl, then a WM_TIMER comes in.

Any ideas?

Thanks,
Curt

June 4th, 1999, 09:37 AM
Hi,

I have had the same thing happened to me. I put a AfxMessageBox() inside my OnTimer() and only for the first couple of times it displayed, afterwards nothing. What's up with CListView?

I'd like to know what the reason and work-around is.

Good luck.

cdehaven
June 4th, 1999, 09:03 PM
I ended up sorting this one out myself. My original OnTimer looked something like:



void MyClass::OnTimer (int nEvent)
{
MessageBeep(0);

CListView::OnTimer(nEvent);
}





I don't have the code in front of me so don't hold me to the syntax... Anyway, I ended up replacing that with this:



void MyClass::OnTimer (int nEvent)
{
if (nEvent == MY_EVENT)
MessageBeep(0);

else
CListView::OnTimer(nEvent);
}





I actually ported this app from a dialog-based app that had that first OnTimer and everything worked fine. But I found that - I guess - if you call the CListView's OnTimer with an event that it's not expecting, it gets heartburn. I tried singlestepping into it once and ended up with an access-vio. Since I was in a hurry to get this app done and onto to other stuff, I was just happy to get it to run.

Force be with you.

Curt

tsaifue
June 11th, 1999, 01:25 AM
I have found the problem is that the listview eat the timer message but I don't know the solution yet.
I suggest you setting the timer process to do the same thing on SetTimer(,,,TimerProc).