Help needed with SetTimer()
Please help me. I can''t get SetTimer() to work right. Initalization succeeds, but timer never lauches either the
TimeProc or the WM_TIMER-event. My call is something like:
SetTimer(hWnd,TIMERX,1000,(TIMERPROC)timeproc);
If I got that right, SetTimer() should only throw a WM_TIMER event, with the last parameter as NULL and that would be just what I need.
The Multimedia timer works fine, but it crashes if run under the Builder and it makes debugging harder. And besides, the basic Timer is good enough for my purposes.
Have anyone come accross the same problem, or have an idea what on earth can be wrong in such a simple thing.
JO
SetTimer EITHER sends a WM_TIMER message to your window, OR calls the proc you supply.
so if you want to catch a message instead of supplying a function, just put 0 instead of timeproc.
SetTimer(hWnd,TIMER_ID,1000,0);
also make sure that TIMER_ID is a value between 0 and 32
so if you want to catch a message instead of supplying a function, just put 0 instead of timeproc.
SetTimer(hWnd,TIMER_ID,1000,0);
also make sure that TIMER_ID is a value between 0 and 32
Yep, that''s what the help said, but doesn''t work. Message WM_TIMER never appears.
I''m beginning to suspect, that there''s something weird in my windows-headers...
I''m beginning to suspect, that there''s something weird in my windows-headers...
TimeProc needs to be a static function. Something that''s never mentioned in the docs, so I missed it the first time too.
At last I found a reason!! Don''t ask why, but if you catch a WM_PAINT in your message-handler, you never get WM_TIMER!
A simple example program worked, so I added my code there line after line until WM_TIMER messages stopped. Boy, that took time.. Can anyone explain why WM_PAINT prevents WM_TIMER messages to arrive? Any other messages seemed not to have the same problem. Amazing isn''t it?
JO
A simple example program worked, so I added my code there line after line until WM_TIMER messages stopped. Boy, that took time.. Can anyone explain why WM_PAINT prevents WM_TIMER messages to arrive? Any other messages seemed not to have the same problem. Amazing isn''t it?
JO
If you always have some form of WM_PAINT message pending (like WM_TIMER, WM_PAINT doesn''t really get queued), then WM_TIMER messages will never be generated.
Take a look at the article "GetMessage and PeekMessage Internals"
http://msdn.microsoft.com/library/techart/msdn_getpeek.htm
Tim
Take a look at the article "GetMessage and PeekMessage Internals"
http://msdn.microsoft.com/library/techart/msdn_getpeek.htm
Tim
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement