Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WM_TIMER and GetTickCount()

Status
Not open for further replies.

monstrum

Programmer
Oct 18, 2000
6
0
0
SE
I can't figure out how to time events in my app.

SetTimer() doesn't seem to send WM_TIMER events to the message que within reasonable precision. (A SetTimer call with 1000 milliseconds on the timeout seem to end up with a WM_TIMER message every 800 to 1200 milliseconds).

And when I call the GetTickCount in my own timer routine the message que seem to get lockup.

I've also tried the timeGetTime() but I get a couple of linker errors even if I included the right header-file (mmsystem.h)

Maybe the error is not in how I use these calls, maybe it is my Peek-,Get- and DispatchMessage calls that are being called in the wrong order or place.

Please help out [sig][/sig]
 
Hi,
Depending on your compiler and if the CPU is a pentium or better you can try
QueryPerformanceCounter(...)l

Dick
 
depending on what you are trying to do, you may want to go about this in different ways. The WM_TIIMER is not an accurate timer and is dependent upon the operating system. You may want to use _IntervalTimerInstruction. I have used it and it is less complicated than WM_TIMER. I use timers often and they can be quite complicated at times and even PhD's in Comp Sci have difficulty with them.
 
You can use the multimedia function timeGetTime(), just include the header mmsystem.h and the library "winmm.lib".
You can include the library via the Settings option in the worksapce explorer.
 
I was reading from one of my Win32 API books, and it stated that WM_TIMER messages can be queued and then sent to windows depending on what Windows is working on, which makes it very unreliable if you want to do something that needs good precision.

Good luck
 
oops...

&quot;WM_TIMER messages can be queued and then sent to ->your program<- depending...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top