IE.cpp
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:2k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. // IE.cpp : Defines the initialization routines for the DLL.
  2. //
  3. #include "stdafx.h"
  4. #include "IE.h"
  5. #include "MainFrame.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /*
  12.   协同浏览模块
  13.   接口
  14.   1 、 创建IE窗口
  15.   2 、 设定url
  16.   数据包的定义可以定义为
  17.   窗口号 id + url
  18.   窗口号是标志着IE窗口的唯一值,通过这个id可以通知远程同id号的窗口的url改变
  19. */
  20. BEGIN_MESSAGE_MAP(CIEApp, CWinApp)
  21. //{{AFX_MSG_MAP(CIEApp)
  22. // NOTE - the ClassWizard will add and remove mapping macros here.
  23. //    DO NOT EDIT what you see in these blocks of generated code!
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CIEApp construction
  28. CIEApp::CIEApp()
  29. {
  30. }
  31. /////////////////////////////////////////////////////////////////////////////
  32. // The one and only CIEApp object
  33. CIEApp theApp;
  34. //创建窗口
  35. extern "C" __declspec( dllexport ) CWnd * CreateIEWnd( void ( * OnIEURL )( void * wParam , CWnd * pWnd , char * buffer , int size ) , void * wParam , const char * user_name )
  36. {
  37. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  38. CMainFrame * frame = new CMainFrame( );
  39. frame->OnIEURL = OnIEURL;
  40. frame->wParam = wParam;
  41. frame->user_name = user_name;
  42. return frame;
  43. }
  44. //设定消息
  45. extern "C" __declspec( dllexport ) void SetIEMessage( CWnd * pIEWnd , char * buffer , int size )
  46. {
  47. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  48. if( ! ::IsWindow( pIEWnd->GetSafeHwnd( ) ) || ! buffer )
  49. return;
  50.     //解析数据包
  51. //id值
  52. int id = *( int * )buffer; buffer += sizeof( int );
  53. //2、用户名
  54. CString username = (char * )buffer; buffer += username.GetLength( ) + sizeof( char );
  55. //3、网址
  56.     //转换为框架窗口
  57. CMainFrame * frame = ( CMainFrame * )pIEWnd;
  58. //查找对应的ie窗口
  59. CIEView * ieView = NULL;
  60. for( int i = 0 ; ; i ++ )
  61. {
  62. ieView = frame->GetView( )->GetIEView( i );
  63.         //找到ie窗口 
  64. if( ! ieView || ( ieView->ieid == id && ieView->username == username ) )
  65. break;
  66. }
  67. if( ! ieView )
  68. {   //创建ie窗口 
  69. ieView = frame->GetView( )->CreateIEView( );
  70.         //给定用户名
  71. ieView->username = username;
  72.         //给定id 
  73. ieView->ieid = id;
  74. }
  75. ieView->Stop( );
  76. //浏览
  77. ieView->Navigate2( buffer );
  78. }