Leaked source code of windows server 2003
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.

79 lines
2.9 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: ThunkProc.h */
  4. /* Description: In order to get rid of the thread. Which causes problems */
  5. /* since we have to marshal we use this timer stuff from ATL. */
  6. /* The basic problem is that we would like to have a timer associated */
  7. /* with an object and this is a way to do so */
  8. /* Author: David Janecek */
  9. /*************************************************************************/
  10. #ifndef __THUNKPROC_H
  11. #define __THUNKPROC_H
  12. /////////////////////////////////////////////////////////////////////////////
  13. // TimerProc thunks
  14. class CTimerProcThunk
  15. {
  16. public:
  17. _AtlCreateWndData cd;
  18. CStdCallThunk thunk;
  19. void Init(TIMERPROC proc, void* pThis)
  20. {
  21. thunk.Init((DWORD_PTR)proc, pThis);
  22. }
  23. };
  24. template <class T>
  25. class ATL_NO_VTABLE CMSDVDTimer {
  26. private:
  27. CTimerProcThunk m_TimerThunk;
  28. HWND m_hwnd;
  29. /*************************************************************************/
  30. /* Function: FakeTimerProc */
  31. /*************************************************************************/
  32. static void CALLBACK FakeTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime){
  33. CMSDVDTimer* pThis = (CMSDVDTimer*)hwnd;
  34. pThis->RealTimerProc(pThis->m_hwnd, uMsg, idEvent, dwTime);
  35. }/* end of function FakeTimerProc */
  36. /*************************************************************************/
  37. /* Function: RealTimerProc */
  38. /*************************************************************************/
  39. void RealTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime){
  40. T* pT = static_cast<T*>(this);
  41. if(NULL == pT){
  42. return;
  43. }/* end of if statement */
  44. pT->TimerProc();
  45. }/* end of function RealTimerProc */
  46. public:
  47. /*************************************************************************/
  48. /* Function: MyTimerClass */
  49. /*************************************************************************/
  50. CMSDVDTimer(HWND hwnd = (HWND)NULL){
  51. m_hwnd = hwnd;
  52. m_TimerThunk.Init(FakeTimerProc, this);
  53. }/* end of function MyTimerClass */
  54. /*************************************************************************/
  55. /* Function: GetTimerProc */
  56. /*************************************************************************/
  57. TIMERPROC GetTimerProc() {
  58. return (TIMERPROC)(m_TimerThunk.thunk.pThunk);
  59. }/* end of function GetTimerProc */
  60. };
  61. #endif // __THUNKPROC_H