Updating window within a period of time

Hi forum,

I'm making a mp3-player, and I have a time bar within the program. I need to update the time bar while the music is playing within a period of time.
Since I couldn't really find info about how to make interrupts I just added some extra codes to the message loop.
It uses the time libary to check if there has been a delay of 1/5 second. Then I use InvalidateRect to update the place where my time bar is.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
	MSG msg;
	clock_t delay;
	delay = clock() + CLOCKS_PER_SEC/10;
	
	RECT rec;
		rec.left = 385;
		rec.top = 41;
		rec.right = 775;
		rec.bottom = 61;

	while (GetMessage(&msg, NULL, 0, 0) > 0) { 
		TranslateMessage(&msg);
		DispatchMessage(&msg);

		if(clock() > delay) {
			delay = clock() + CLOCKS_PER_SEC/10;
			SetFocus(hwnd);
			InvalidateRect(hwnd,&rec,false);
		}
	}

return (int) msg.wParam;


My problem is, that it only updates when the window receives another message, like when I'm moving my mouse or so.
Do you have a good solution on how I could update the window within a period of time?

Regards,

Simon H.A.

I think you can create a timer which would send a message when specified amount of time passes:
http://msdn.microsoft.com/en-us/library/ms644901(v=VS.85).aspx#creating_timer
http://msdn.microsoft.com/en-us/library/ms644906(v=VS.85).aspx
That solved my problem.
Thanks!
Topic archived. No new replies allowed.