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 in a non-CWnd class

Timer in a non-CWnd class

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 2 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.
  • A Offline
    A Offline
    anderslundsgard
    wrote on last edited by
    #1

    I have created a generic class (not derived from CWnd). When I call one function in that class I like it to generate a call to another member function of the same class after about 3 seconds. Tips on how to accomplish that? Thanks / Anders _____________________________ ...and justice for all APe

    A 1 Reply Last reply
    0
    • A anderslundsgard

      I have created a generic class (not derived from CWnd). When I call one function in that class I like it to generate a call to another member function of the same class after about 3 seconds. Tips on how to accomplish that? Thanks / Anders _____________________________ ...and justice for all APe

      A Offline
      A Offline
      anderslundsgard
      wrote on last edited by
      #2

      VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ) { AfxMessageBox("TimerProc"); } bool CMyClass::Func() { SetTimer( NULL, 1, 500, TimerProc); … } Got the following compiler error: error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (struct HWND__ *,unsigned int,unsigned long,unsigned long)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)' _____________________________ ...and justice for all APe

      S 1 Reply Last reply
      0
      • A anderslundsgard

        VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ) { AfxMessageBox("TimerProc"); } bool CMyClass::Func() { SetTimer( NULL, 1, 500, TimerProc); … } Got the following compiler error: error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (struct HWND__ *,unsigned int,unsigned long,unsigned long)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)' _____________________________ ...and justice for all APe

        S Offline
        S Offline
        Sujan Christo
        wrote on last edited by
        #3

        Hi, Within the Func() function use SetTimer as SetTimer( NULL, 1, 500, (TIMERPROC)TimerProc); This will work SUjan

        A 1 Reply Last reply
        0
        • S Sujan Christo

          Hi, Within the Func() function use SetTimer as SetTimer( NULL, 1, 500, (TIMERPROC)TimerProc); This will work SUjan

          A Offline
          A Offline
          anderslundsgard
          wrote on last edited by
          #4

          What should a simple coder like me do without you? Really Thanks! _____________________________ ...and justice for all APe

          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