www.gusucode.com > VC++远程视频监控系统源代码-源码程序 > VC++远程视频监控系统源代码-源码程序/code/接收端/接收端/RevPlayThread.cpp

    // RevPlayThread.cpp : implementation file
//

#include "stdafx.h"
#include "winsock2.h"
#include "RevPlayThread.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

HANDLE CRevPlayThread::m_hEventRevPlayThreadKilled;

/////////////////////////////////////////////////////////////////////////////
// CRevPlayThread

IMPLEMENT_DYNCREATE(CRevPlayThread, CWinThread)

CRevPlayThread::CRevPlayThread()
{
}

CRevPlayThread::~CRevPlayThread()
{
}

BOOL CRevPlayThread::InitInstance()
{//创建接收播放窗口
	// TODO:  perform and per-thread initialization here

	CWnd* pParent = CWnd::FromHandle(m_hwndParent);
	CRect rect;
	CoInitialize(NULL);
	pParent->GetClientRect(&rect);
	//创建接收播放窗口
	BOOL bReturn = m_wndRevPlay.Create(_T("接收播放"),
		WS_CHILD | WS_VISIBLE, rect, pParent);

	//将m_pMainWnd设置为新创建的CRevPlayWnd窗口
	//保证当CRevPlayWnd窗口被删除时,线程被自动删除
	if(bReturn)
		m_pMainWnd = &m_wndRevPlay;
	return bReturn;
}

int CRevPlayThread::ExitInstance()
{
	// TODO:  perform any per-thread cleanup here
	CoUninitialize();
	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CRevPlayThread, CWinThread)
	//{{AFX_MSG_MAP(CRevPlayThread)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRevPlayThread message handlers

CRevPlayThread::CRevPlayThread(HWND hwndParent):m_hwndParent(hwndParent)
{
 
}

void CRevPlayThread::operator delete(void *p)
{
 	SetEvent(m_hEventRevPlayThreadKilled);
    CWinThread::operator delete(p);
}