www.pudn.com > WBDraw.rar > WBDraw.cpp


// WBDraw.cpp : Defines the initialization routines for the DLL. 
// 
 
#include "stdafx.h" 
#include  
 
#include "MyWnd.h" 
#include "resource.h" 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
 
static AFX_EXTENSION_MODULE WBDrawDLL = { NULL, NULL }; 
 
extern "C" int APIENTRY 
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 
{ 
	// Remove this if you use lpReserved 
	UNREFERENCED_PARAMETER(lpReserved); 
 
	if (dwReason == DLL_PROCESS_ATTACH) 
	{ 
		TRACE0("WBDRAW.DLL Initializing!\n"); 
		 
		// Extension DLL one-time initialization 
		if (!AfxInitExtensionModule(WBDrawDLL, hInstance)) 
			return 0; 
 
		// Insert this DLL into the resource chain 
		// NOTE: If this Extension DLL is being implicitly linked to by 
		//  an MFC Regular DLL (such as an ActiveX Control) 
		//  instead of an MFC application, then you will want to 
		//  remove this line from DllMain and put it in a separate 
		//  function exported from this Extension DLL.  The Regular DLL 
		//  that uses this Extension DLL should then explicitly call that 
		//  function to initialize this Extension DLL.  Otherwise, 
		//  the CDynLinkLibrary object will not be attached to the 
		//  Regular DLL's resource chain, and serious problems will 
		//  result. 
 
		new CDynLinkLibrary(WBDrawDLL); 
	} 
	else if (dwReason == DLL_PROCESS_DETACH) 
	{ 
		TRACE0("WBDRAW.DLL Terminating!\n"); 
		// Terminate the library before destructors are called 
		AfxTermExtensionModule(WBDrawDLL); 
	} 
	return 1;   // ok 
} 
 
class WBInterface{ 
public: 
	////   ×¢²á»Øµ÷º¯Êý 
	virtual void RegisterCallBackObject(HANDLE hwnd,WBCallBackInterface *pCallBack)=0; 
 
	virtual HANDLE InitWB(CWnd *hWnd,CRect m_cRect)=0; 
 
	virtual void DrawMsg(HANDLE hwnd ,long m_SendMsg, short m_nLen) =0; 
 
	virtual void ReSize(HANDLE hwnd ,CRect m_cRect)=0; 
	 
	virtual void CloseWB(HANDLE hwnd)=0; 
}; 
 
class MyMediaInterface : public WBInterface 
{ 
public: 
	MyMediaInterface(){ 
	} 
 
	~MyMediaInterface(){ 
	} 
 
	virtual void RegisterCallBackObject(HANDLE hwnd,WBCallBackInterface *pCallBack){ 
		MyWnd* m_myWnd=(MyWnd*)hwnd; 
		m_myWnd->RegCallBackFun(pCallBack); 
	}; 
 
	HANDLE InitWB(CWnd *hWnd,CRect m_cRect){ 
		MyWnd* m_MyWnd = new MyWnd; 
		int iRetCod=0; 
 
		iRetCod=m_MyWnd->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,m_cRect, hWnd, AFX_IDW_PANE_FIRST, NULL); 
		if(!iRetCod){ 
			TRACE("MyWnd Create failed!\n"); 
			return false; 
		} 
 
		return (HANDLE)m_MyWnd; 
	}; 
 
	void DrawMsg(HANDLE hwnd,long m_SendMsg, short m_nLen){ 
		MyWnd* m_myWnd=(MyWnd*)hwnd; 
		m_myWnd->DrawMsg(m_SendMsg, m_nLen); 
	} 
 
	void ReSize(HANDLE hwnd ,CRect m_cRect){ 
		MyWnd* m_myWnd=(MyWnd*)hwnd; 
		m_cRect.left=m_cRect.left-10; 
		m_myWnd->MoveWindow(m_cRect,true); 
	} 
 
	void CloseWB(HANDLE hwnd){ 
		MyWnd* m_myWnd=(MyWnd*)hwnd; 
		m_myWnd->DestroyWindow(); 
		delete m_myWnd; 
	}; 
public: 
	WBCallBackInterface * g_pCallBackInterface; 
}; 
	 
 
MyMediaInterface  m_myInterface ; 
WBInterface * GetWBInterface( ) 
{ 
	WBInterface * pMin=&m_myInterface; 
	return pMin; 
}