MainView.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:6k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // MainView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "conference.h"
- #include "MainView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- IMPLEMENT_DYNCREATE( CMainView , CView )
- extern CConferenceApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CMainView
- CMainView::CMainView()
- {
- this->chatWnd = NULL;
- this->wbWnd = NULL;
- this->ieWnd = NULL;
- this->fileWnd = NULL;
- this->shareWnd = NULL;
- }
- CMainView::~CMainView()
- {
- }
- BEGIN_MESSAGE_MAP(CMainView, CView)
- //{{AFX_MSG_MAP(CMainView)
- ON_WM_SIZE()
- ON_WM_CREATE()
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainView drawing
- int CMainView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if ( CView::OnCreate(lpCreateStruct) == -1 )
- return -1;
- static int i = 0;
- CRect rc;
- this->GetClientRect( &rc );
- //第一个视图,分割窗口
- if( ! i && this->m_wndSplitter.CreateStatic( this , 2 , 1 ) )
- {
- i ++;
- this->m_wndSplitter.CreateView( 0 , 0 , RUNTIME_CLASS( CMainView ) , CSize( rc.Width( ) , rc.Height( ) / 2 ) , NULL );
- this->m_wndSplitter.CreateView( 1 , 0 , RUNTIME_CLASS( CMainView ) , CSize( 0 , 0 ) , NULL );
- this->m_wndSplitter.SetRowInfo( 0 , ::GetSystemMetrics( SM_CYSCREEN ) * 3 / 4 , 0 );
- }//第2个视图,标签窗口
- else if( i == 1 )
- {
- i ++;
- this->m_tab.Create( TCS_TABS | WS_CHILD | WS_VISIBLE | TCS_BOTTOM | TCS_FOCUSNEVER , rc , this , 0 );
- CFont font;
- font.CreatePointFont( 100 , "新宋体" );
- this->m_tab.SetFont( &font );
- font.Detach( );
- this->wbWnd = ::CreateWBWnd( CMainView::OnWB , this , theApp.GetClient( ).GetUserName( ) );
- this->m_tab.AddWnd( this->wbWnd , "电子白板" , false);
- this->ieWnd = ::CreateIEWnd( CMainView::OnIEURL , this , theApp.GetClient( ).GetUserName( ) );
- this->m_tab.AddWnd( this->ieWnd , "协同浏览" , false );
- this->shareWnd = ::CreateShareWnd( CMainView::OnShare , this , theApp.GetClient( ).GetUserName( ) );
- this->m_tab.AddWnd( this->shareWnd , "程序共享" , false );
- this->fileWnd = ::CreateFileWnd( CMainView::OnFile , this , theApp.GetClient( ).GetUserName( ) );
- this->m_tab.AddWnd( this->fileWnd , "文件传输" , false );
- }//第三个视图,文字聊天窗口
- else if ( i == 2 )
- {
- if( this->chatWnd = ::CreateChatWnd( CMainView::OnChat , this , theApp.GetClient( ).GetUserName( ) ) )
- {
- this->chatWnd->SetParent( this );
- this->chatWnd->ModifyStyle( WS_CAPTION | WS_BORDER | WS_THICKFRAME , 0 );
- this->chatWnd->ShowWindow( SW_SHOW );
- }
- }
- return 0;
- }
- CWnd * CMainView::GetTabWnd( int index )
- {
- CMainView * view = ( CMainView * )this->m_wndSplitter.GetPane( 0 , 0 );
- switch( index )
- {
- case 0 : return view->wbWnd;
- case 1 : return view->ieWnd;
- case 2 : return view->shareWnd;
- case 3 : return view->fileWnd;
- }
- return NULL;
- }
- void CMainView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
- if( this->GetWindow( GW_CHILD ) )
- this->GetWindow( GW_CHILD )->MoveWindow( 0 , 0 , cx , cy );
- }
- void CMainView::OnChat( void * pContext , CWnd * pWnd , char * buffer , int size )
- {
- CMainView * pThis = ( CMainView * )pContext;
- theApp.GetClient( ).SendModulePackage( PModulePackage::CHAT , buffer , size );
- //回显
- ::SetChatMessage( pThis->chatWnd , buffer , size );
- }
- void CMainView::OnWB( void * pContext , CWnd * pWnd , char * buffer , int size )
- {
- CMainView * pThis = ( CMainView * )pContext;
- theApp.GetClient( ).SendModulePackage( PModulePackage::WB , buffer , size );
- }
- void CMainView::OnIEURL( void * pContext , CWnd * pWnd , char * buffer , int size )
- {
- CMainView * pThis = ( CMainView * )pContext;
- theApp.GetClient( ).SendModulePackage( PModulePackage::IE , buffer , size );
- }
- void CMainView::OnFile( void * pContext , CWnd * pWnd , char * buffer , int size )
- {
- CMainView * pThis = ( CMainView * )pContext;
- if( ! buffer || ! size )
- pThis->GetParent( )->GetParent( )->GetParent( )->SendMessage( WM_ADD_USER , ( WPARAM )pWnd );
- else
- theApp.GetClient( ).SendModulePackage( PModulePackage::FILE , buffer , size );
- }
- bool CMainView::OnShare( void * pContext , CWnd * pWnd , char * buffer , int size )
- {
- CMainView * pThis = ( CMainView * )pContext;
- if( buffer&& size )
- theApp.GetClient( ).SendModulePackage( PModulePackage::SHARE , buffer , size );
- return ! theApp.GetClient( ).GetConferenceName( ).empty( );
- }
- void CMainView::SetModulePackage( int module , char * buffer , int size )
- {
- CMainView * view = ( CMainView * )this->m_wndSplitter.GetPane( 0 , 0 );
- switch( module )
- {//聊天
- case PModulePackage::CHAT :
- {
- view = ( CMainView * )this->m_wndSplitter.GetPane( 1 , 0 );
- ::SetChatMessage( view->chatWnd , buffer , size );
- }break;
- case PModulePackage::WB :
- ::SetWBMessage( view->wbWnd , buffer , size ); break;
- //协同浏览
- case PModulePackage::IE :
- ::SetIEMessage( view->ieWnd , buffer , size ); break;
- //文件传输
- case PModulePackage::FILE :
- ::SetFileMessage( view->fileWnd , buffer , size ); break;
- //应用程序共享
- case PModulePackage::SHARE :
- ::SetShareMessage( view->shareWnd , buffer , size ); break;
- }
- }
- void CMainView::OnDestroy()
- {
- if( this->chatWnd )
- this->chatWnd->SendMessage( WM_CLOSE );
- if( this->wbWnd )
- this->wbWnd->SendMessage( WM_CLOSE );
- if( this->ieWnd )
- this->ieWnd->SendMessage( WM_CLOSE );
- if( this->fileWnd )
- this->fileWnd->SendMessage( WM_CLOSE );
- if( this->shareWnd )
- this->shareWnd->SendMessage( WM_CLOSE );
- CView::OnDestroy();
- }