CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2009
    Posts
    10

    How to test if KillTimer has been called?

    As the title says.

    I can't seem to find anything on MSDN on this subject.
    The timers being used aren't HANDLE variables; rather, they are declared like #define IDT_TIMER 100.

    Thanks!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: How to test if KillTimer has been called?

    What do you mean by "How to test"?
    Just set a breakpoint and/or use TRACE and debug!
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: How to test if KillTimer has been called?

    And how IDT_TIMER 100 is used?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: How to test if KillTimer has been called?

    #define IDT_TIMER 100
    You don't need resources to use a timer... you can simply use settimer/killtimer.

  5. #5
    Join Date
    Jul 2009
    Posts
    10

    Re: How to test if KillTimer has been called?

    Sorry, I guess I should have been more clear!
    I want to programmatically, at some point in the code, test if a certain timer has been killed. If so, I want to do nothing. Otherwise, do something.

    IDT_TIMER is used like: SetTimer(hWnd, IDT_TIMER);

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: How to test if KillTimer has been called?

    Quote Originally Posted by jojo080889 View Post
    IDT_TIMER is used like: SetTimer(hWnd, IDT_TIMER);
    1. SetTimer API has for arguments, not two.
    2. Why do you need (or think that you need) to "programmatically, at some point in the code, test if a certain timer has been killed"?
    Victor Nijegorodov

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: How to test if KillTimer has been called?

    You could always maintain a flag that you set to true when you start the timer and false when you kill it.

  8. #8
    Join Date
    Jul 2009
    Posts
    10

    Re: How to test if KillTimer has been called?

    whoops, sorry, I meant to write KillTimer, not SetTimer!

    Well, it's kind of complicated to explain why I need to do this, but I'll try my best.
    I'm working on code that is basically video calls over IP. When Phone A calls Phone B, Phone A starts a timer for the time they have to wait for a person to answer. Phone B, upon receiving the request, has a timer that starts for the time they have to answer the call before the call will time out.
    These timers should be for the same length, but there is a little bit of delay related to the time it takes for one phone to even realize that another phone is calling it.
    So, sometimes, Phone B will be able answer even when Phone A's timer has been killed, and weird stuff happens.
    Therefore, I want Phone A to be able to test if its timer has been killed before a call starts. If it's been killed, ignore the call. If not, proceed as normal.

    If there really is not way to see if a timer has been stopped, I'll probably go with a flag, thanks It's just kind of a pain in the butt with the way the code is set up.

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to test if KillTimer has been called?

    Quote Originally Posted by jojo080889 View Post
    If there really is not way to see if a timer has been stopped, I'll probably go with a flag, thanks It's just kind of a pain in the butt with the way the code is set up.
    There really isn't any Win32 api to do it. I suppose if you know the original SetTimer parameters for the ID that you would like to check, then you could call KillTimer and look for a successful return value. If KillTimer returns a success, then you know the timer was running and you can use the parameters to restart the timer. Of course that would interupt the current timer interval and could be up to a bit more than twice the regular interval.

Tags for this Thread

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