I am trying to make a stopwatch program...but I keep freezing the program(at least it doesn't freeze C++ like VB froze itself)...
This is the code that does the actual time management:
how do I stop it from freezing?PHP Code:Pause(50000);
int active = 1;
int milli = 0;
int secs = 0;
int mins =0;
while(active==1) {
milli++;
if(milli>=10) {
milli=0;
secs++;
}
if(secs>=60) {
secs=0;
mins++;
}
char buf[40];
int m = milli;
itoa(m, buf, 10); // 10 is the radix (number base)
SendMessage(ghWnd_milli, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(m, buf, 10));
int s = secs;
itoa(s, buf, 10); // 10 is the radix (number base)
SendMessage(ghWnd_secs, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(s, buf, 10));
int mi = mins;
itoa(mi, buf, 10); // 10 is the radix (number base)
SendMessage(ghWnd_mins, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(mi, buf, 10));
//=======NOW IS A PAUSE FUNCTION=========
void Pause(unsigned long amount)
{ //creates a delay with the duration of amount.
unsigned long t = GetTickCount();
while((GetTickCount() - t) < amount);
}


(at least it doesn't freeze C++ like VB froze itself)...
Reply With Quote