PDA

Click to See Complete Forum and Search --> : is there Timer in VC++??


hazel
Sep 26th, 2002, 02:47 AM
hello.
may i know is there a Timer control in VC++ and how to use that??
can provide me some code samples also? hehe..

thanks..

Bazza81
Sep 26th, 2002, 03:13 AM
You may use the varius timer API functions. For instance, the SetTimer() function will create the timer and call your specified call-back function every n milliseconds. Hence, the KillTimer() function will destroy the timer you created when using the SetTimer() function.

The best way I find is to just run through an infinate loop using GetTickCount() instead.

hazel
Sep 26th, 2002, 04:12 AM
ok.. thanks.
i'll try that out .
so doesn't VC++ have something like a Timer Control, ?
like in Borland C builder..

thank you..

parksie
Sep 26th, 2002, 06:46 AM
Do you actually *know* C++?

I wouldn't recommend starting with MFC.

C++ is *not* a RAD language, like VB or C++ Builder.

hazel
Sep 26th, 2002, 09:52 PM
ok.. fine..
thanks 4 ur advice..

:mad:

Eras3r
Sep 27th, 2002, 07:43 PM
lol, why would you want to use a control? ... Just use SetTimer, and you can create a callback function. ... Works pretty much like the Timer control in VB, but better. :)

CornedBee
Sep 28th, 2002, 07:42 AM
Actually all the VB timer control does is calling SetTimer...

parksie
Sep 28th, 2002, 07:47 AM
You're better off using timeSetEvent, it's far more reliable.

kedaman
Sep 28th, 2002, 08:36 AM
what's timeSetEvent?

parksie
Sep 28th, 2002, 08:39 AM
The multimedia timers. Far more stable, and accurate to 1ms.

kedaman
Sep 28th, 2002, 08:42 AM
I have a vague memory of using them in VB at sometime, and that they used to crash the IDE :S

parksie
Sep 28th, 2002, 08:50 AM
It's not difficult to crash VB. If you have pointers to things they get juggled around and then the callbacks don't work.

kedaman
Sep 28th, 2002, 08:53 AM
hmm.. I dont care about VB anyway, so doesnt matter, probably going to be useful.

CornedBee
Sep 28th, 2002, 03:32 PM
But if accuracy or reliability is not needed (such as for an autosave, it doesn't need to come exactly to the millisecond), SetTimer is better because it's easier to use and doesn't require an answering thread. And timeSetEvent lays several restrictions on the user.