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. COM
  4. COM and Timer

COM and Timer

Scheduled Pinned Locked Moved COM
c++comregexhelpquestion
3 Posts 1 Posters 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    In my COM object with MFC support I want to install a timer: ::SetTimer(NULL, TIMER_ID, 1000, (TIMERPROC)TimerProc); Then I declare TimerProc() in COM class as: VOID CALLBACK TimerProc( HWND hwnd, // handle to window for timer messages UINT message, // WM_TIMER message UINT idTimer, // timer identifier DWORD dwTime) ; // current system time and define as: VOID CALLBACK TimerProc( HWND hwnd, // handle to window for timer messages UINT message, // WM_TIMER message UINT idTimer, // timer identifier DWORD dwTime) // current system time { // Do something } But I've got a compiler error: error C2440: 'type cast' : cannot convert from '' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)' None of the functions with this name in scope match the target type What am I doing wrong ?

    L 1 Reply Last reply
    0
    • L Lost User

      In my COM object with MFC support I want to install a timer: ::SetTimer(NULL, TIMER_ID, 1000, (TIMERPROC)TimerProc); Then I declare TimerProc() in COM class as: VOID CALLBACK TimerProc( HWND hwnd, // handle to window for timer messages UINT message, // WM_TIMER message UINT idTimer, // timer identifier DWORD dwTime) ; // current system time and define as: VOID CALLBACK TimerProc( HWND hwnd, // handle to window for timer messages UINT message, // WM_TIMER message UINT idTimer, // timer identifier DWORD dwTime) // current system time { // Do something } But I've got a compiler error: error C2440: 'type cast' : cannot convert from '' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)' None of the functions with this name in scope match the target type What am I doing wrong ?

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

      1. If you really "declare TimerProc() in COM class as:... " - this is a mistake, you cannot use in such way member fuction as a callback. 2. If not so, just void CALLBACK TimerProcedure(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTimer) { //some_action; } STDMETHODIMP CZZZControl::SomeMethod() { m_nEvent = ::SetTimer(some_params); } 3. May be you are trying to use not ::SetTimer, but CWindow::SetTimer Wish you luck!

      L 1 Reply Last reply
      0
      • L Lost User

        1. If you really "declare TimerProc() in COM class as:... " - this is a mistake, you cannot use in such way member fuction as a callback. 2. If not so, just void CALLBACK TimerProcedure(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTimer) { //some_action; } STDMETHODIMP CZZZControl::SomeMethod() { m_nEvent = ::SetTimer(some_params); } 3. May be you are trying to use not ::SetTimer, but CWindow::SetTimer Wish you luck!

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

        First of all Thanks for your help. I have found at MSDN site that for MFC application it is necessary to declare a callback function as a static, so I did and now it works fine. Dimitri.

        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