Advertisement

timer

Started by May 20, 2000 07:32 AM
2 comments, last by gameprogrammerwiz 24 years, 7 months ago
ok, back in the day, the visual basic days, all you had to do is drag and drop a timer onto the form (window). now i''m using c++ and i have no idea how to use timers. is there any way i can make a program with a timer that triggered every 60 seconds? this timer also has to be running in the background...in other words, the timer has to be counting down the seconds WHILE my programming is still running other functions. -mike
==============================
whats a signature?
htm[s]l[/s]
What you''d need to do is call the SetTimer function

Here''s how you use it.
SetTimer(hwnd, TIMER_ID, 60000, NULL);

hwnd = handle of the application''s window
TIMER_ID = integer variable that will hold the timer''s ID
60000 = 60 seconds(timer inverval, in miliseconds)
NULL = callback function(check the SDK on how to implement this)

That should solve your problem
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Advertisement
or you could use good ol'' GetTickCount.
DWORD time;
time=GetTickCount();
this gets an acurate measure of the time in milliseconds. to convert to seconds shouldn''t be too hard.
if(time%1000==1)
seconds++;
or something like that
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
I forgot to mention that you need to make a starting time.
DWORD start_time;
DWOR time;
start_time=GetTickCount();
while(!done)
{
time=GetTickCount()-start_time;
...
}
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

This topic is closed to new replies.

Advertisement