MainFrame.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:8k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // MainFrame.cpp : implementation file
- //
- #include "stdafx.h"
- #include "IE.h"
- #include "MainFrame.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- CMainFrame::CMainFrame( )
- {
- this->view = new CTabView( );
- if( ! this->Create( NULL , "协同浏览" , WS_OVERLAPPEDWINDOW , rectDefault , NULL , 0 ) )
- {
- delete this->view;
- this->view = NULL;
- }
- this->OnIEURL = NULL;
- this->wParam = NULL;
- this->user_name = "";
- }
- CMainFrame::~CMainFrame( )
- {
- }
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_OPEN, OnOpen)
- ON_COMMAND(ID_SAVE, OnSave)
- ON_COMMAND(ID_BACKWORD, OnBackword)
- ON_COMMAND(ID_FORWORD, OnForword)
- ON_COMMAND(ID_STOP, OnStop)
- ON_COMMAND(ID_FLUSH, OnFlush)
- ON_COMMAND(ID_HOME, OnHome)
- ON_COMMAND(ID_SEARCH, OnSearch)
- ON_COMMAND(ID_FAVORITE, OnFavorite)
- ON_COMMAND(ID_HISTORY, OnHistory)
- ON_COMMAND(ID_FONT, OnFont)
- ON_WM_CHAR()
- ON_UPDATE_COMMAND_UI(ID_FAVORITE, OnUpdateFavorite)
- //}}AFX_MSG_MAP
- ON_NOTIFY(NM_CLICK, IDC_TREE, OnSelchangedTree)
- ON_COMMAND_RANGE( ID_FONT_BIGGEST , ID_FONT_SMALLEST , OnFontMenu )
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR,
- // ID_INDICATOR_CAPS,
- // ID_INDICATOR_NUM,
- // ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if ( CFrameWnd::OnCreate(lpCreateStruct) == -1 )
- return -1;
- this->reBar.Create( this );
- //工具栏
- this->toolBar.CreateEx( this , TBSTYLE_FLAT | TBSTYLE_TRANSPARENT |TBSTYLE_TOOLTIPS );
- this->toolBar.LoadToolBar(IDR_MAIN_TOOLBAR );
- CImageList imglist;
- imglist.Create( 21 , 20 , ILC_COLORDDB|ILC_MASK, 35, 1);
- CBitmap bmp;
- bmp.LoadBitmap( IDB_COLDTOOLBAR );
- imglist.Add( &bmp , RGB( 255 , 0 , 255 ) );
- bmp.Detach( );
- this->toolBar.GetToolBarCtrl( ).SetImageList( &imglist );
- imglist.Detach( );
- imglist.Create( 21 , 20 , ILC_COLORDDB|ILC_MASK, 35, 1);
- bmp.LoadBitmap( IDB_HOTTOOLBAR );
- imglist.Add( &bmp , RGB( 255 , 0 , 255 ) );
- bmp.Detach( );
- CString text;
- CRect rc;
- for( int i = 0; i < this->toolBar.GetCount( ); i ++ )
- {
- text.LoadString( this->toolBar.GetItemID( i ) );
- text.Delete( 'n' );
- this->toolBar.SetButtonText( i , text );
- this->toolBar.GetItemRect( 0 , &rc );
- this->toolBar.SetSizes( CSize( rc.Width( ) , rc.Height( ) ) , CSize( 16 , 20 ) );
- }
- this->toolBar.GetToolBarCtrl( ).SetHotImageList( &imglist );
- this->toolBar.GetToolBarCtrl( ).HideButton( ID_SEARCH );
- this->toolBar.GetToolBarCtrl( ).HideButton( ID_HISTORY );
- imglist.Detach( );
- this->reBar.AddBar( &this->toolBar , RGB( 10 , 10 , 10 ) , RGB( 214 , 239 , 255 ) , NULL , RBBS_NOGRIPPER | RBBS_HIDDEN );
- //地址栏
- this->addrCombo.Create( WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP , CRect( 0 , 0 , 1 , 200 ) , this , ID_ADDR_COMBO );
- this->editAddr.SubclassWindow( this->addrCombo.GetEditCtrl( )->GetSafeHwnd( ) );
- this->editAddr.RegisterGetURLFunction( CMainFrame::OnAddress , this );
- this->reBar.AddBar( &this->addrCombo , RGB( 10 , 10 , 10 ) , RGB( 214 , 239 , 255 ) , "地址栏" ,RBBS_NOGRIPPER | RBBS_BREAK | RBBS_HIDDEN );
- //状态栏
- this->statusBar.CreateEx( this );
- this->statusBar.ShowWindow( SW_HIDE );
- this->statusBar.SetIndicators( indicators , sizeof( indicators ) / sizeof( UINT ) );
- //视图
- this->view->Create( NULL , NULL , AFX_WS_DEFAULT_VIEW , CRect( 0 , 0 , 0 , 0 ) , this , AFX_IDW_PANE_FIRST , NULL );
- //自动搜索地址
- HINSTANCE hIns = LoadLibrary("shlwapi.dll");
- if(hIns != NULL)
- {
- typedef HRESULT (CALLBACK* LPFNDLLFUNC1)(HWND ,DWORD);
- LPFNDLLFUNC1 lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hIns, "SHAutoComplete");
- if(lpfnDllFunc1!=NULL)
- lpfnDllFunc1(this->addrCombo.GetSafeHwnd( ) , 0xe );
- FreeLibrary(hIns);
- }
- //收藏夹
- this->favorite_bar.Create( this );
- this->ShowControlBar( &this->favorite_bar , FALSE , FALSE );
- //历史纪录
- this->history_bar.Create( this );
- this->ShowControlBar( &this->history_bar , FALSE , FALSE );
- return 0;
- }
- void CMainFrame::SetStatusText( LPCSTR text )
- {
- if( this->statusBar )
- this->statusBar.SetWindowText( text );
- }
- void CMainFrame::OnAddress( void * wParam )
- {
- CMainFrame * pThis = ( CMainFrame * )wParam;
- CString url;
- pThis->editAddr.GetWindowText( url );
- if( ! url.IsEmpty( ) )
- {
- CIEView * ieView = pThis->view->CreateIEView( );
- //设定id
- ieView->ieid = ( int )ieView;
- ieView->username = pThis->user_name;
- //通知外部
- ieView->m_bNotify = TRUE;
- ieView->Navigate2( url );
- }
- }
- void CMainFrame::OnOpen()
- {
- CFileDialog dlg( true , NULL , NULL , OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT , "网页文件(*.html,*.htm,*.jsp,*.asp)|*.html,*.htm,*.jsp,*.asp|所有文件(*.*)|*.*||");
- if( dlg.DoModal( ) == IDOK )
- {
- this->editAddr.SetWindowText( dlg.GetPathName( ) );
- this->OnAddress( this );
- }
- }
- void CMainFrame::OnSave()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- ieView->ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
- }
- void CMainFrame::OnBackword()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- {
- ieView->m_bNotify = TRUE;
- ieView->GoBack( );
- }
- }
- void CMainFrame::OnForword()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- {
- ieView->m_bNotify = TRUE;
- ieView->GoForward( );
- }
- }
- void CMainFrame::OnStop()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- ieView->Stop( );
- }
- void CMainFrame::OnFlush()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- ieView->Refresh2( REFRESH_NORMAL );
- }
- void CMainFrame::OnHome()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- {
- ieView->m_bNotify = TRUE;
- ieView->GoHome( );
- }
- }
- void CMainFrame::OnSearch()
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- ieView->GoSearch( );
- }
- void CMainFrame::OnFavorite()
- {
- this->ShowControlBar( &this->favorite_bar , ! this->favorite_bar.IsVisible( ) , FALSE );
- }
- void CMainFrame::OnUpdateFavorite(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck( this->favorite_bar.IsVisible( ) );
- }
- void CMainFrame::OnHistory()
- {
- this->ShowControlBar( &this->history_bar , ! this->history_bar.IsVisible( ) , FALSE );
- }
- void CMainFrame::OnFont( )
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- {
- COleVariant vaZoomFactor;
- ieView->ExecWB( OLECMDID_ZOOM , OLECMDEXECOPT_DONTPROMPTUSER , NULL , &vaZoomFactor );
- CRect rc;
- this->toolBar.GetItemRect( 10 , &rc );
- this->toolBar.ClientToScreen( &rc );
- CMenu menu;
- menu.LoadMenu( IDR_FONT_MENU );
- menu.GetSubMenu( 0 )->CheckMenuItem( 4 - vaZoomFactor.intVal , MF_CHECKED | MF_BYPOSITION );
- menu.GetSubMenu( 0 )->TrackPopupMenu( TPM_LEFTALIGN , rc.left , rc.bottom + 1 , this );
- }
- }
- void CMainFrame::OnFontMenu( UINT id )
- {
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ieView )
- {
- COleVariant vaZoomFactor( ( long )( ID_FONT_BIGGEST + 4 - id ) );
- ieView->ExecWB( OLECMDID_ZOOM , OLECMDEXECOPT_DONTPROMPTUSER , &vaZoomFactor , NULL );
- }
- }
- void CMainFrame::OnSelchangedTree( NMHDR* pNMHDR, LRESULT* pResult )
- {
- CString url;
- this->favorite_bar.GetCurURL( url );
- if( ! url.IsEmpty( ) )
- {
- this->editAddr.SetWindowText( url );
- CIEView * ieView = this->GetView( )->GetIEView( );
- if( ! ieView )
- this->OnAddress( this );
- else
- {
- ieView->m_bNotify = TRUE;
- ieView->Navigate2( url );
- }
- }
- }