Timer example...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
spyro
Posts: 17
Joined: Mon Mar 14, 2005 4:05 pm

Timer example...

Post by spyro »

Hi
I need a little timer example which uses the SetTimer function, because i wasn't able to get it working.
If someone has a example post it please.

spyro
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

No idea what SetTimer you're talking about but search Google (yes it's easy) or:

http://www.koders.com/?s=SetTimer&_%3Ala=Cpp&_%3Ali=*
spyro
Posts: 17
Joined: Mon Mar 14, 2005 4:05 pm

Post by spyro »

Here is the definition of the function:

Code: Select all

UINT_PTR SetTimer(      

    HWND hWnd,
    UINT_PTR nIDEvent,
    UINT uElapse,
    TIMERPROC lpTimerFunc
);
Here is the full definition -> Link
I tried to replace the last parameter of this function (IpTimerFunc) with the name of my function, but it didn't work.
Any ideas?

spyro
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

What's the compiler error?
spyro
Posts: 17
Joined: Mon Mar 14, 2005 4:05 pm

Post by spyro »

Here is the error :evil:

Code: Select all

expected constructor, destructor, or type conversion before '(' token 
expected `,' or `;' before '(' token 
[Build Error]  [main.o] Error 1 
PS: I'm using DevCPP

spyro
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

And your code?
spyro
Posts: 17
Joined: Mon Mar 14, 2005 4:05 pm

Post by spyro »

Code: Select all

#include <windows.h>

void test()
{
}

SetTimer(hwnd, NULL, 1000, test);

int main()
{
}

CuteAlien
Admin
Posts: 9721
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You try to call a function outside of any other function. That won't work in c++.
Put the SetTimer within the braces {} of main()
spyro
Posts: 17
Joined: Mon Mar 14, 2005 4:05 pm

Post by spyro »

Yeah!
Thank you CuteAlien, the timer works now! :D

spyro
Post Reply