The question is shown in the title. I recently used CreateTimerQueueTimer() to create a loop for a simple game running at 30 fps. It worked all right, but I noticed that sometimes the stuff I have drawn on the screen will "flash", that is, suddenly disappear for a short time (one frame, maybe?) and reappear again in the following frames. And even in the title screen scenes, where all the callback function has to do is to call TextOut() and SelectObject() a few times, the flashing happens. And when it flashes, not all the stuff in the window disappear all at once. It's only one or few lines of text, a few rectangles, etc. that disappears at once. And all of the things I've drawn flashes.
I found out that the flashing has something to do with the fps, because if I set the fps to 10, the flashing stops. But even with the least fps I can set to without the user feeling weird, 24 fps, the flashing still continues.
It's okay if you have no idea what I'm talking about or what caused the problem above, I just wanted the answer to the question. It's obvious to me that CreateTimerQueueTimer() couldn't provide me with a game loop, but I really know nothing better than this function. Is there another function I can use?
Why don't you use a normal timer?
Check for keys pressed , update your game in WM_TIMER, invalidate the window and in WM_PAINT you paint everything - if necessary use double buffering.
Thanks, I get what you are saying about using a normal timer, but I don't quite understand what you mean by "in WM_PAINT you paint everything." Shouldn't I paint every time I update the game?
And if I use SetTimer(), the flashing still happens... And the fps seemed slower than CreateTimeQueueTimer() even though I used 1000 / 30 for both of them.
And one more question: Is it better to use the WM_TIMER message or the TimerProc() callback?