Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
657 B

  1. #include "precomp.h"
  2. #include "extimer.h"
  3. CExclusiveTimer::CExclusiveTimer(void)
  4. : m_nTimerId(0),
  5. m_hWnd(NULL)
  6. {
  7. }
  8. CExclusiveTimer::~CExclusiveTimer(void)
  9. {
  10. Kill();
  11. }
  12. void CExclusiveTimer::Kill(void)
  13. {
  14. if (m_hWnd && m_nTimerId)
  15. {
  16. ::KillTimer( m_hWnd, m_nTimerId );
  17. m_hWnd = NULL;
  18. m_nTimerId = 0;
  19. }
  20. }
  21. void CExclusiveTimer::Set( HWND hWnd, UINT nTimerId, UINT nMilliseconds )
  22. {
  23. Kill();
  24. m_hWnd = hWnd;
  25. m_nTimerId = nTimerId;
  26. if (m_hWnd && m_nTimerId)
  27. {
  28. ::SetTimer( m_hWnd, m_nTimerId, nMilliseconds, NULL );
  29. }
  30. }
  31. UINT CExclusiveTimer::TimerId(void) const
  32. {
  33. return m_nTimerId;
  34. }