RevPlayThread.cpp
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:2k
源码类别:

VC书籍

开发平台:

Visual C++

  1. // RevPlayThread.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "winsock2.h"
  5. #include "RevPlayThread.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. HANDLE CRevPlayThread::m_hEventRevPlayThreadKilled;
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRevPlayThread
  14. IMPLEMENT_DYNCREATE(CRevPlayThread, CWinThread)
  15. CRevPlayThread::CRevPlayThread()
  16. {
  17. }
  18. CRevPlayThread::~CRevPlayThread()
  19. {
  20. }
  21. BOOL CRevPlayThread::InitInstance()
  22. {//创建接收播放窗口
  23. // TODO:  perform and per-thread initialization here
  24. CWnd* pParent = CWnd::FromHandle(m_hwndParent);
  25. CRect rect;
  26. CoInitialize(NULL);
  27. pParent->GetClientRect(&rect);
  28. //创建接收播放窗口
  29. BOOL bReturn = m_wndRevPlay.Create(_T("接收播放"),
  30. WS_CHILD | WS_VISIBLE, rect, pParent);
  31. //将m_pMainWnd设置为新创建的CRevPlayWnd窗口
  32. //保证当CRevPlayWnd窗口被删除时,线程被自动删除
  33. if(bReturn)
  34. m_pMainWnd = &m_wndRevPlay;
  35. return bReturn;
  36. }
  37. int CRevPlayThread::ExitInstance()
  38. {
  39. // TODO:  perform any per-thread cleanup here
  40. CoUninitialize();
  41. return CWinThread::ExitInstance();
  42. }
  43. BEGIN_MESSAGE_MAP(CRevPlayThread, CWinThread)
  44. //{{AFX_MSG_MAP(CRevPlayThread)
  45. // NOTE - the ClassWizard will add and remove mapping macros here.
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CRevPlayThread message handlers
  50. CRevPlayThread::CRevPlayThread(HWND hwndParent):m_hwndParent(hwndParent)
  51. {
  52.  
  53. }
  54. void CRevPlayThread::operator delete(void *p)
  55. {
  56.   SetEvent(m_hEventRevPlayThreadKilled);
  57.     CWinThread::operator delete(p);
  58. }