CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Posts
    61

    Help to Kill Timer

    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




  2. #2
    Join Date
    May 1999
    Location
    WA
    Posts
    65

    Re: Help to Kill Timer

    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

  3. #3
    Join Date
    May 1999
    Posts
    61

    Re: It's right but..

    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


  4. #4
    Join Date
    May 1999
    Location
    WA
    Posts
    65

    Re: It's right but..

    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

  5. #5
    Join Date
    May 1999
    Posts
    61

    More information

    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



  6. #6
    Join Date
    May 1999
    Location
    WA
    Posts
    65

    Re: More information

    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

  7. #7
    Join Date
    May 1999
    Posts
    61

    Thanks for everything

    Thank you very much.
    Good Luck Troy.
    Drago




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured