Sounds and a GUI

I was wondering if anyone knew how to make a simple GUI that had a button (made from a PNG) that started a timer. I was also wondering if anyone knew how to make a sound play when a counter reached 0 (zero).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* clock example: countdown */  
#include <iostream.h>                         
#include <stdio.h>
#include <time.h>
#include <windows.h>

void wait ( int seconds )
{
	clock_t endwait;
	endwait = clock () + seconds * CLOCKS_PER_SEC ;
	while (clock() < endwait) {}
}

int main ()
{
	int n;
	printf ("Starting countdown...\n");
	for (n=20; n>0; n--)
	{
		printf ("%d\n",n);
		wait (60);
	}
	printf ("FIRE!!!\n");
	printf ("Countdown over\n");

	cin.get();
	return 0;
}


This is all the code I have. When 60 seconds go by, the number is decreased by one until it reaches 0 (zero).
gui's in windows are much different than command line programs, and far more complex, but read these, and you should be set!

NOTE: if you are interested in learning more about windows API and creating GUI apps, read "Programming Windows" by Charles Petzold, and look in MSDN library (where the second link is located)

win32 basics tutorial: (for creating a GUI)
http://www.winprog.org/tutorial/

playing a sound: (simple, no DirectSound or OpenAL, just win32 api)
http://msdn.microsoft.com/en-us/library/ms712879.aspx
Yeah...also, you do realize your "wait" function will use 100% of the available CPU while it is waiting? I would suggest using Sleep() (since you are using windows) since that will not use up the CPU.
But it also runs through the entire program at once.
Topic archived. No new replies allowed.