How to use Windows Timer API
To create a timer:
SetTimer(g_AppWindow, //
handle to main window
IDT_TIMER1, // timer
identifier
//1000/60,
// 1/60-second interval
41,//1000/24,
// 1/24-second interval
(TIMERPROC)NULL); // no
timer callback
To use the timer to do sth:
case WM_TIMER:
switch (LOWORD(wParam))
{
case IDT_TIMER1:
// do sth here
// time your code
g_tick2
= g_pfnGetTickCount();
if (1)
{
WCHAR buffer[50];
swprintf_s(buffer,
50, L"Debug: %d ms passed ...\n\0",
(g_tick2
- g_tick1));
OutputDebugStringW(buffer);
}
g_tick1 = g_tick2;

0 Comments:
Post a Comment
<< Home