MainFrame.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:10k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // MainFrame.cpp : implementation file
- //
- #include "stdafx.h"
- #include "WB.h"
- #include "MainFrame.h"
- #include "DrawWBWnd.h"
- #include "WndDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- CMainFrame::CMainFrame()
- {
- this->view = new CDrawView( this );
- this->m_bRgn = false;
- this->m_bWnd = false;
- this->cArrow = ::AfxGetApp( )->LoadCursor( MAKEINTRESOURCE( IDC_ARROW ) );
- this->cErase = ::AfxGetApp( )->LoadCursor( MAKEINTRESOURCE( IDC_ERASE ) );
- this->cLock = ::AfxGetApp( )->LoadCursor( MAKEINTRESOURCE( IDC_LOCK ) );
- this->cPen = ::AfxGetApp( )->LoadCursor( MAKEINTRESOURCE( IDC_PEN ) );
- this->cPen1 = ::AfxGetApp( )->LoadCursor( MAKEINTRESOURCE( IDC_PEN1 ) );
- this->cBeam = ::AfxGetApp( )->LoadStandardCursor( MAKEINTRESOURCE( IDC_IBEAM ) );
- this->cCross = ::AfxGetApp( )->LoadStandardCursor( MAKEINTRESOURCE( IDC_CROSS ) );
- this->Create( NULL , "电子白板" , WS_OVERLAPPEDWINDOW | WS_VISIBLE , CFrameWnd::rectDefault , NULL , 0 );
- }
- CMainFrame::~CMainFrame()
- {
- }
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- ON_COMMAND_RANGE( IDC_RADIO1 , IDC_RADIO16 , OnTool )
- ON_COMMAND_RANGE( IDC_1 , IDC_28 , OnColor )
- ON_COMMAND( IDC_LINE , OnLine )
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if ( CFrameWnd::OnCreate(lpCreateStruct) == -1 )
- return -1;
- this->view->Create( NULL , NULL , AFX_WS_DEFAULT_VIEW , CRect( 0 , 0 , 0 , 0 ) , this , AFX_IDW_PANE_FIRST , NULL );
- this->EnableDocking( CBRS_ALIGN_ANY );
- this->InitColor( );
- this->InitTool( );
- return 0;
- }
- void CMainFrame::InitTool( void )
- {
- this->toolBar.Create( this , IDD_TOOL_DIALOG , CBRS_LEFT , 1 );
- this->reToolBar.Create( this , RBS_AUTOSIZE , WS_CHILD | WS_VISIBLE | CBRS_LEFT );
- this->reToolBar.AddBar( &this->toolBar , RGB( 214 , 239 , 255 ) , RGB( 214 , 239 , 255 ) , NULL , RBBS_NOGRIPPER | RBBS_HIDDEN | RBBS_FIXEDSIZE );
- CImageList imglist;
- imglist.Create( IDB_WB_TOOL , 16 , 1 , RGB( 192 , 192 , 192 ) );
- CButton * btn = NULL;
- HICON hIcon = NULL;
- CString text;
- CImageList imglist2;
- imglist2.Create( IDB_OPEN_SAVE_BITMAP , 15 , 1 , RGB( 255 , 0 , 0 ) );
- btn = ( CButton * )this->toolBar.GetDlgItem( IDC_OPEN );
- if( btn )
- {
- btn->ModifyStyle( 0 , BS_ICON );
- btn->GetWindowText( text );
- if( text.IsEmpty( ) )
- text = " ";
- ToolTip( btn->GetSafeHwnd( ) , text );
- hIcon = imglist2.ExtractIcon( 0 );
- btn->SetIcon( hIcon );
- }
- btn = ( CButton * )this->toolBar.GetDlgItem( IDC_SAVE );
- if( btn )
- {
- btn->ModifyStyle( 0 , BS_ICON );
- btn->GetWindowText( text );
- if( text.IsEmpty( ) )
- text = " ";
- ToolTip( btn->GetSafeHwnd( ) , text );
- hIcon = imglist2.ExtractIcon( 1 );
- btn->SetIcon( hIcon );
- }
- for( int i = 0; i < imglist.GetImageCount( ); i ++ )
- {
- btn = ( CButton * )this->toolBar.GetDlgItem( IDC_RADIO1 + i );
- if( btn )
- {
- btn->ModifyStyle( 0 , BS_ICON );
- btn->GetWindowText( text );
- if( text.IsEmpty( ) )
- text = " ";
- ToolTip( btn->GetSafeHwnd( ) , text );
- hIcon = imglist.ExtractIcon( i );
- btn->SetIcon( hIcon );
- }
- }
- this->linectrl.SubclassDlgItem( IDC_LINE , &this->toolBar );
- }
- void CMainFrame::InitColor( void )
- {
- this->colorBar.Create( this , IDD_COLOR_DIALOG , CBRS_BOTTOM , 2 );
- this->rcColorBar.Create( this , RBS_AUTOSIZE , WS_CHILD | WS_VISIBLE | CBRS_BOTTOM );
- this->rcColorBar.AddBar( & this->colorBar , RGB( 214 , 239 , 255 ) , RGB( 214 , 239 , 255 ) , NULL , RBBS_NOGRIPPER | RBBS_HIDDEN | RBBS_FIXEDSIZE );
- this->curClrCtrl.SubclassDlgItem( IDC_SELECT , &this->colorBar );
- //1黑色
- this->clrCtrl[ 0 ].SubclassDlgItem( IDC_1 , &this->colorBar );
- //2白色
- this->clrCtrl[ 1 ].SubclassDlgItem( IDC_2 , &this->colorBar );
- this->clrCtrl[ 1 ].SetColor( RGB( 255 , 255 , 255 ) );
- //3深灰
- this->clrCtrl[ 2 ].SubclassDlgItem( IDC_3 , &this->colorBar );
- this->clrCtrl[ 2 ].SetColor( RGB( 128 , 128 , 128 ) );
- //4浅灰
- this->clrCtrl[ 3 ].SubclassDlgItem( IDC_4 , &this->colorBar );
- this->clrCtrl[ 3 ].SetColor( RGB( 192 , 192 , 192 ) );
- //5深红
- this->clrCtrl[ 4 ].SubclassDlgItem( IDC_5 , &this->colorBar );
- this->clrCtrl[ 4 ].SetColor( RGB( 128 , 0 , 0 ) );
- //6浅红
- this->clrCtrl[ 5 ].SubclassDlgItem( IDC_6 , &this->colorBar );
- this->clrCtrl[ 5 ].SetColor( RGB( 255 , 0 , 0 ) );
- //7深黄
- this->clrCtrl[ 6 ].SubclassDlgItem( IDC_7 , &this->colorBar );
- this->clrCtrl[ 6 ].SetColor( RGB( 128 , 128 , 0 ) );
- //8浅黄
- this->clrCtrl[ 7 ].SubclassDlgItem( IDC_8 , &this->colorBar );
- this->clrCtrl[ 7 ].SetColor( RGB( 255 , 255 , 0 ) );
- //9深绿
- this->clrCtrl[ 8 ].SubclassDlgItem( IDC_9 , &this->colorBar );
- this->clrCtrl[ 8 ].SetColor( RGB( 0 , 128 , 0 ) );
- //10浅绿
- this->clrCtrl[ 9 ].SubclassDlgItem( IDC_10 , &this->colorBar );
- this->clrCtrl[ 9 ].SetColor( RGB( 0 , 255 , 0 ) );
- //11
- this->clrCtrl[ 10 ].SubclassDlgItem( IDC_11 , &this->colorBar );
- this->clrCtrl[ 10 ].SetColor( RGB( 0 , 128 , 128 ) );
- //12
- this->clrCtrl[ 11 ].SubclassDlgItem( IDC_12 , &this->colorBar );
- this->clrCtrl[ 11 ].SetColor( RGB( 0 , 255 , 255 ) );
- //13
- this->clrCtrl[ 12 ].SubclassDlgItem( IDC_13 , &this->colorBar );
- this->clrCtrl[ 12 ].SetColor( RGB( 0 , 0 , 128 ) );
- //14
- this->clrCtrl[ 13 ].SubclassDlgItem( IDC_14 , &this->colorBar );
- this->clrCtrl[ 13 ].SetColor( RGB( 0 , 0 , 255 ) );
- //15
- this->clrCtrl[ 14 ].SubclassDlgItem( IDC_15, &this->colorBar );
- this->clrCtrl[ 14 ].SetColor( RGB( 128 , 0 , 128 ) );
- //16
- this->clrCtrl[ 15 ].SubclassDlgItem( IDC_16, &this->colorBar );
- this->clrCtrl[ 15 ].SetColor( RGB( 255 , 0 , 255 ) );
- //17
- this->clrCtrl[ 16 ].SubclassDlgItem( IDC_17, &this->colorBar );
- this->clrCtrl[ 16 ].SetColor( RGB( 128 , 128 , 64 ) );
- //18
- this->clrCtrl[ 17 ].SubclassDlgItem( IDC_18, &this->colorBar );
- this->clrCtrl[ 17 ].SetColor( RGB( 255 , 255 , 128 ) );
- //19
- this->clrCtrl[ 18 ].SubclassDlgItem( IDC_19, &this->colorBar );
- this->clrCtrl[ 18 ].SetColor( RGB( 0 , 64 , 64 ) );
- //20
- this->clrCtrl[ 19 ].SubclassDlgItem( IDC_20, &this->colorBar );
- this->clrCtrl[ 19 ].SetColor( RGB( 0 , 255 , 128 ) );
- //21
- this->clrCtrl[ 20 ].SubclassDlgItem( IDC_21, &this->colorBar );
- this->clrCtrl[ 20 ].SetColor( RGB( 0 , 128 , 255 ) );
- //22
- this->clrCtrl[ 21].SubclassDlgItem( IDC_22, &this->colorBar );
- this->clrCtrl[ 21 ].SetColor( RGB( 128 , 255 , 255 ) );
- //23
- this->clrCtrl[ 22 ].SubclassDlgItem( IDC_23, &this->colorBar );
- this->clrCtrl[ 22 ].SetColor( RGB( 0 , 64 , 128 ) );
- //24
- this->clrCtrl[ 23 ].SubclassDlgItem( IDC_24, &this->colorBar );
- this->clrCtrl[ 23 ].SetColor( RGB( 128 , 128 , 255 ) );
- //25
- this->clrCtrl[ 24 ].SubclassDlgItem( IDC_25, &this->colorBar );
- this->clrCtrl[ 24 ].SetColor( RGB( 64 , 0 , 255 ) );
- //26
- this->clrCtrl[ 25 ].SubclassDlgItem( IDC_26, &this->colorBar );
- this->clrCtrl[ 25 ].SetColor( RGB( 255 , 0 , 128 ) );
- //27
- this->clrCtrl[ 26 ].SubclassDlgItem( IDC_27, &this->colorBar );
- this->clrCtrl[ 26 ].SetColor( RGB( 128 , 64 , 0 ) );
- //28
- this->clrCtrl[ 27 ].SubclassDlgItem( IDC_28, &this->colorBar );
- this->clrCtrl[ 27 ].SetColor( RGB( 255 , 128 , 64 ) );
- }
- //工具选择
- void CMainFrame::OnTool( UINT id )
- {
- if( ! this->toolBar.GetDlgItem( id )->IsWindowVisible( ) )
- return;
- int index = id - IDC_RADIO1;
- bool empty = true;
- switch( index )
- {
- case 0 : index = CDraw::SELECT; empty = false; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cArrow ); break;
- case 1 : index = CDraw::SELECT; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cErase ); break;
- case 2 : index = CDraw::TEXT ; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cBeam ); break;
- case 3 : index = CDraw::PEN1; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cPen1 );break;
- case 4 : index = CDraw::PEN; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cPen );break;
- case 5 : index = CDraw::LINE; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cCross );break;
- case 6 : index = CDraw::RECT; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cCross );break;
- case 7 : index = CDraw::RECT; empty = false; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cCross );break;
- case 8 : index = CDraw::CIRCLE; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cCross );break;
- case 9 : index = CDraw::CIRCLE; empty = false; ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->cCross );break;
- case 10 : break;
- case 11 : this->view->GetIterator( )->SetIterator( );break;
- case 12 : break;
- case 13 : break;
- case 14 :
- {
- if( ! this->m_bRgn )
- {
- CWndDialog dlg( IDD_RGN_DIALOG );
- if( dlg.DoModal( ) == IDOK )
- this->m_bRgn = dlg.m_check;
- else
- return;
- }
- index = CDraw::WBWND;
- }
- break;
- case 15 :
- {
- if( ! this->m_bWnd )
- {
- CWndDialog dlg( IDD_WND_DIALOG );
- if( dlg.DoModal( ) == IDOK )
- this->m_bWnd = dlg.m_check;
- else
- return;
- }
- index = CDraw::WBWND1;
- }
- break;
- }//选择画笔
- this->view->SelectDraw( index , this->curClrCtrl.GetColor( ) , this->linectrl.GetWidth( ) , empty );
- }
- //颜色选择
- void CMainFrame::OnColor( UINT id )
- {
- CColorCtrl * clr = ( CColorCtrl * )this->colorBar.GetDlgItem( id );
- if( clr )
- this->curClrCtrl.SetColor( clr->GetColor( ) );
- //设定颜色
- if( this->view->GetDraw( ) )
- this->view->GetDraw( )->SetColor( this->curClrCtrl.GetColor( ) );
- }
- //线条选择
- void CMainFrame::OnLine( void )
- { //设定线型
- if( this->view->GetDraw( ) )
- this->view->GetDraw( )->SetWidth( this->linectrl.GetWidth( ) );
- }
- BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
- {
- if( ! CFrameWnd::OnCommand(wParam, lParam) )
- return this->view->SendMessage( WM_COMMAND , wParam , lParam );
- return true;
- }