Timers

This is a discussion on Timers within the Windows Programming forums, part of the Platform Specific Boards category; Is there a way to use more than one timer in a windows program through WM_TIMER in WndProc?...

  1. #1
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972

    Question Timers

    Is there a way to use more than one timer in a windows program through WM_TIMER in WndProc?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    yes give them different ids.
    Last edited by Stoned_Coder; 02-28-2003 at 08:02 PM.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Could you give me an example of this?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Look its not too hard.

    Code:
    In WM_CREATE ....
    
    SetTimer(hwnd,IDT_T1,5000,(TIMERPROC)NULL);
    SetTimer(hwnd,IDT_T2,1000,(TIMERPROC)NULL);
    
    in WM_TIMER.....
    
    case WM_TIMER:
         switch(wParam)
          {
              case: IDT_T1: // do stuff every 5 secs.
                        break;
              case: IDT_T2: // do stuff every second.
                        break;
            }
    Just like that.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Ok, thanks. I just wasn't sure what to put under WM_TIMER...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Check out my game! It's sorta incomplete, but it works and it's the first one I've made. Let me know what you think and if there are any major problems.

    Oh, and if it seems familiar to you then...it probably is...
    Attached Files Attached Files
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Threads and Timers
    By scioner in forum C Programming
    Replies: 8
    Last Post: 03-22-2008, 08:56 AM
  2. Enumerating timers and hotkeys
    By maxorator in forum Windows Programming
    Replies: 3
    Last Post: 01-01-2007, 11:47 AM
  3. switch cases and timers
    By soranz in forum C++ Programming
    Replies: 5
    Last Post: 10-02-2005, 07:43 PM
  4. Timers, Timers, Timers!
    By Stan100 in forum Game Programming
    Replies: 9
    Last Post: 01-24-2003, 04:45 PM
  5. Timers
    By Mox in forum Windows Programming
    Replies: 2
    Last Post: 11-09-2001, 04:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21