Click to See Complete Forum and Search --> : Help to Kill Timer


Drago
May 3rd, 1999, 03:49 PM
Hi,
I need your help !!
I'd like to use SetTimer with CALLBACK FUNCTION like 3rd parameter in SetTimer
I try this
::SetTimer(NULL, 1, 1000, CMyFrame::TimerProc) in CMainFrame
It's working, but I have a problem with KillTimer function. I can't stop Timer.
Please help me. What must I do. And how can I call KillTimer corectlly.

Thank you in advance
Drago

Troy T
May 3rd, 1999, 03:59 PM
So when you're calling KillTimer, you're doing it exactly like this?:KillTimer( NULL, 1 );

Is that right? When you initialized the timer, you didn't give it a parent window, instead you told it "NULL", and in doing that, you must call the corresponding KillTimer routine with "NULL" in the first parameter (which would have been a window handle)..

Is that the way you're calling KillTimer?


- Troy

Drago
May 3rd, 1999, 04:47 PM
Thank you for answer but
I have't any open views and if I use SetTimer(1,100, NULL) I can't set timer on.
Please tell me how can I use a handle to window like 3rd parameter.
Thank you very much
Drago

Troy T
May 4th, 1999, 12:51 AM
I wasn't referring to how you're setting the timer, but how you're killing it. You must be consistant in how you're setting and killing the timer. If you use a HWND in one, you need to use that same HWND in the other. Be consistant. :)

- Troy

Drago
May 5th, 1999, 01:00 PM
Hi,
Here is my all problem:
I use MDI application. I'd like to swich on my timer in CMainFrame and I'd like stop this timer in same class (CMainFrame)
Now I just use this:
SetTimer(NULL, 1, 1000, TimerProc)
TimerProc is defined like EXTERN CALLBACK function
and I kill timer like that:
KillTimer(NULL, 1)
But there is a problem with KillTimer. When I call KillTimer, this function return FALSE.
What can I do .
Please help me!
Thanks a lot.
Drago

Troy T
May 5th, 1999, 04:17 PM
After reading all of the help files in MSDN about the Set/Kill Timer fuctions, the only thing I get think of is for you to call GetLastError() and see what the specific problem is with the KillTimer function call.. Sorry I couldn't be much help afterall, I thought for sure that I noticed your HWND's were different, and that it was the reason the call failed.

Good luck.

- Troy

Drago
May 6th, 1999, 02:42 PM
Thank you very much.
Good Luck Troy.
Drago