Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TIMER API

TIMER API

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xiaowei
    wrote on last edited by
    #1

    does anyone has a sample code on timer which allows you to call any procedure you want to call say, every 30 ms ? Thanks for helping

    L E 2 Replies Last reply
    0
    • X xiaowei

      does anyone has a sample code on timer which allows you to call any procedure you want to call say, every 30 ms ? Thanks for helping

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time ) { .................. } // Set timer SetTimer(hwnd, // handle to main window IDT_TIMER1, // timer identifier 30, // 30ms interval (TIMERPROC) MyTimerProc); // timer callback // Delete timer BOOL KillTimer( HWND hwnd, // handle to window UINT_PTR uIDEvent // timer identifier );

      L 1 Reply Last reply
      0
      • X xiaowei

        does anyone has a sample code on timer which allows you to call any procedure you want to call say, every 30 ms ? Thanks for helping

        E Offline
        E Offline
        Erik Funkenbusch
        wrote on last edited by
        #3

        Standard timers are not very accurate, since they depend on windows messages. If you have a lot of messages in your queue, then timer requests can be delayed. You're better off using the multimedia timers, which have a much higher resolution than normal timers and are waitable (using WaitFor(Single/Multiple)Object(s)).

        1 Reply Last reply
        0
        • L Lost User

          VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time ) { .................. } // Set timer SetTimer(hwnd, // handle to main window IDT_TIMER1, // timer identifier 30, // 30ms interval (TIMERPROC) MyTimerProc); // timer callback // Delete timer BOOL KillTimer( HWND hwnd, // handle to window UINT_PTR uIDEvent // timer identifier );

          L Offline
          L Offline
          Larry
          wrote on last edited by
          #4

          sorrie I am new to C++ programming and I want to enquire which part of the code am I suppose to insert the procedures I want to call whenever this 30 ms interval is up?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups