www.pudn.com > 200518174534292.rar > AviCap.cpp


// AviCap.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ParkSys.h" 
#include "AviCap.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// AviCap 
 
CAviCap::CAviCap() 
{ 
} 
 
CAviCap::~CAviCap() 
{ 
} 
 
BOOL CAviCap::capInit(CWnd* pParentWnd, int tx, int ty, 
					  int bx, int by, int avi_WindowID, 
					  int DeviceIndex) 
{ 
		m_hWndCap = capCreateCaptureWindow((LPSTR)"Capture Window", 
					WS_CHILD|WS_VISIBLE, 
					tx,ty,bx,by,  
					 pParentWnd->GetSafeHwnd(), avi_WindowID); 
 
	capDriverConnect(m_hWndCap, DeviceIndex); 
	capOverlay (m_hWndCap, TRUE); 
 
	if (m_hWndCap == NULL) 
		return FALSE; 
 
	//ÉèÖôíÎó´¦Àíº¯Êý 
	capSetCallbackOnError(m_hWndCap, CAviCap::ErrorCallbackProc); 
	return TRUE; 
} 
void CAviCap::capClose() 
{ 
	capOverlay(m_hWndCap, 0); 
	capDriverDisconnect(m_hWndCap); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// AviCap message handlers 
// ErrorCallbackProc: error callback function  
// hWnd:              capture window handle  
// nErrID:            error code for the encountered error  
// lpErrorText:       error text string for the encountered error  
//  
 
LRESULT CAviCap::ErrorCallbackProc(HWND hWnd, int nErrID, LPSTR lpErrorText) 
{ 
	if (!hWnd)  
        return FALSE;  
	 
    if (nErrID == 0)            // Starting a new major function.  
        return TRUE;            // Clear out old errors.  
	 
    // Show the error identifier and text.  
	CString strMsg; 
	strMsg.Format("%s¡£´íÎóºÅ£º%d", lpErrorText, nErrID); 
	 
    AfxMessageBox(strMsg, MB_OK | MB_ICONEXCLAMATION);  
	 
    return (LRESULT) TRUE;  
}