tags:

views:

169

answers:

2

I'm trying to make a timer in c++. I'm new to c++. I found this code snippet

UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);

I put it in my global variables and it tells me

Error 1 error C2373: 'SetTimer' : redefinition; different type modifiers

I'm not sure what this means. Is there a more proper way to define a timer?

I'm not using mfc / afx

Thanks

+1  A: 

That's not a function call -- that's a function declaration, which you are probably already #including from somewhere. What you need is the actual SetTimer call from your code.

Can you post your code where you're trying to set up the timer, and the function you want it to call when it triggers?

Joe
+3  A: 

You should call it like this:

void CALLBACK TimerProc(
 HWND hwnd, 
 UINT uMsg, 
 UINT idEvent, 
 DWORD dwTime 
)
{
 //do something
}

SetTimer(NULL, NULL, 1000, OnTimer);

This would set a timer for 1 second and will call TimerProc when it expires. Read TimerProc MSDN here: http://msdn.microsoft.com/en-us/library/ms644907%28VS.85%29.aspx

Igor Zevaka