Use a timer.
Setup:
Code:
/* Get the start time. */
g_timeStart = time();
/* Set a timer to fire every second (1000 milliseconds) */
SetTimer(NULL, 0, 1000, TimerProc);
Your TimerProc:
Code:
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
time_t timeNow = time();
int seconds_count = (int) difftime(timeNow, g_timeStart);
char buffer[50];
int hours = seconds_count / 3600; /* 3600 seconds in an hour. */
int minutes = (seconds_count % 3600) / 60; /* Get remainder after removing hours
* and divide by 60 to get minutes. */
int seconds = (seconds_count % 60); /* Get remainder after removing minutes. */
sprintf(buffer, "%d:%02d:%02d", hours, minutes, seconds);
SetWindowText(hwndStatus, buffer);
}