code_junkie

How to receive timer events in CWinApp with MFC?

Nov 11th, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. UINT_PTR uTimerId = SetTimer(NULL, 0, 2000, NULL);
  2. TRACE(_T("Timer created - ID=%xn"), uTimerId);
  3.  
  4. BOOL CMyFunkyApp::PreTranslateMessage(MSG* pMsg)
  5. {
  6. if (pMsg->message == WM_TIMER)
  7. {
  8. TRACE(_T("Timer fired - ID=%xn"), pMsg->wParam);
  9. }
  10.  
  11. return CWinApp::PreTranslateMessage(pMsg);
  12. }
  13.  
  14. void CALLBACK TimerCallback(HWND, UINT, UINT_PTR id, DWORD dwTime)
  15. {
  16. TRACE(_T("Timer fired - ID=%xn"), id);
  17. }
  18.  
  19. //...
  20.  
  21. UINT_PTR uTimerId = SetTimer(NULL, 0, 2000, &TimerCallback);
  22. TRACE(_T("Timer created - ID=%xn"), uTimerId);
Add Comment
Please, Sign In to add comment