⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wb.cpp

📁 电子白板程序
💻 CPP
字号:
// WB.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "WB.h"
#include "DrawFrame.h"

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

extern BOOL WINAPI CoolSB_InitializeApp(void);
extern BOOL WINAPI CoolSB_UninitializeApp(void);
//
//	Note!
//
//		If this DLL is dynamically linked against the MFC
//		DLLs, any functions exported from this DLL which
//		call into MFC must have the AFX_MANAGE_STATE macro
//		added at the very beginning of the function.
//
//		For example:
//
//		extern "C" BOOL PASCAL EXPORT ExportedFunction()
//		{
//			AFX_MANAGE_STATE(AfxGetStaticModuleState());
//			// normal function body here
//		}
//
//		It is very important that this macro appear in each
//		function, prior to any calls into MFC.  This means that
//		it must appear as the first statement within the 
//		function, even before any object variable declarations
//		as their constructors may generate calls into the MFC
//		DLL.
//
//		Please see MFC Technical Notes 33 and 58 for additional
//		details.
//

/////////////////////////////////////////////////////////////////////////////
// CWBApp

BEGIN_MESSAGE_MAP(CWBApp, CWinApp)
	//{{AFX_MSG_MAP(CWBApp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWBApp construction

CWBApp::CWBApp()
{
}


BOOL CWBApp::InitInstance() 
{
	CoolSB_InitializeApp();
	
	return CWinApp::InitInstance();
}

int CWBApp::ExitInstance() 
{
	CoolSB_UninitializeApp();

	return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CWBApp object
/*
   2005-4-28 设计电子白板,所有的画图属性都在DRAW结构里,所有的画图类都继承CDrawBase
   所有的图元都保存在map里面,每个图元有自己唯一的名称标志name
*/
CWBApp theApp;
//创建白板窗口
extern "C" __declspec( dllexport ) HWND WB_Create( bool ( * OnWB )( void * pContext , HWND hWnd , const char * buffer , int size ) , void * pContext )
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CDrawFrame * frame = new CDrawFrame( );

	if( frame->GetSafeHwnd() )
    {   //回调函数
		frame->GetView( )->OnWB = OnWB;
		//用户自定义参数
		frame->GetView( )->pContext = pContext;
		//保存类
		::SetProp( frame->GetSafeHwnd() , "__WB__" , frame );

		return frame->GetSafeHwnd();
	}
	delete frame;

	return NULL;
}
//修改用户名
extern "C" __declspec( dllexport ) void WB_SetName( HWND hWnd , const char * username )
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState( ) );

	if( ::IsWindow( hWnd ) )
	{
		CDrawFrame * frame = ( CDrawFrame * )::GetProp( hWnd , "__WB__" );

		if( frame )

			frame->GetView()->username = username;
	}
}
//设定消息
extern "C" __declspec( dllexport ) void WB_SetMessage( HWND hWnd , const char * buffer , int size )
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState( ) );

	if( ::IsWindow( hWnd ) )
	{
		CDrawFrame * frame = ( CDrawFrame * )::GetProp( hWnd , "__WB__" );
        //通过消息处理同步问题
		if( frame )
		{
			char * buf = new char[ size ];

			if( buf )
			{
				memcpy( buf , buffer , size );

				frame->GetView()->PostMessage( WM_PARSE_DATA , ( WPARAM )buf , ( LPARAM )size );
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -