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

IP电话/视频会议

开发平台:

Visual C++

  1. // ConferenceDialog.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "conference.h"
  5. #include "ConferenceDialog.h"
  6. #include "MainFrame.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern CConferenceApp theApp;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CConferenceDialog dialog
  15. CConferenceDialog::CConferenceDialog(CWnd* pParent /*=NULL*/)
  16. : CDialog(CConferenceDialog::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CConferenceDialog)
  19. //}}AFX_DATA_INIT
  20. this->mainFrame = NULL;
  21. }
  22. void CConferenceDialog::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CConferenceDialog)
  26. DDX_Control(pDX, IDC_TAB, m_tab);
  27. DDX_Control(pDX, IDC_JOIN_CONFERENCE_BUTTON, m_btn2);
  28. DDX_Control(pDX, IDC_CREATE_CONFERENCE_BUTTON, m_btn1);
  29. DDX_Control(pDX, IDC_RECIPIENT_LIST, m_rlist);
  30. DDX_Control(pDX, IDC_ONLINE_LIST, m_olist);
  31. DDX_Control(pDX, IDC_CONFERENCE_LIST, m_clist);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CConferenceDialog, CDialog)
  35. //{{AFX_MSG_MAP(CConferenceDialog)
  36. ON_WM_SIZE()
  37. ON_WM_NCHITTEST()
  38. ON_NOTIFY(NM_DBLCLK, IDC_ONLINE_LIST, OnDblclkOnlineList)
  39. ON_NOTIFY(LVN_ITEMCHANGED, IDC_RECIPIENT_LIST, OnItemchangedRecipientList)
  40. ON_NOTIFY(NM_DBLCLK, IDC_CONFERENCE_LIST, OnDblclkConferenceList)
  41. ON_NOTIFY(NM_DBLCLK, IDC_RECIPIENT_LIST, OnDblclkRecipientList)
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CConferenceDialog message handlers
  46. BOOL CConferenceDialog::OnInitDialog() 
  47. {
  48. CDialog::OnInitDialog();
  49.     //会议信息
  50. this->m_tab.AddWnd( &this->m_olist , "在线用户" , false );
  51. this->m_tab.AddWnd( &this->m_clist , "会议列表" , false  );
  52. this->m_tab.AddWnd( &this->m_rlist , "我的会议室" , false  );
  53. this->m_tab.SetCurSel( 0 );
  54.     //注册回调消息 
  55. this->m_tab.RegisterTabChangeEvent( CConferenceDialog::OnTab , this );
  56.     //在线用户
  57. if( this->m_olist )
  58. {
  59. this->m_olist.SetExtendedStyle( LVS_EX_FULLROWSELECT );
  60. this->m_olist.InsertColumn( 0 , "在线用户" , LVCFMT_CENTER , this->m_olist.GetStringWidth( " 在线用户 " ) );
  61. this->m_olist.InsertColumn( 1 , "当前状态" , LVCFMT_CENTER , this->m_olist.GetStringWidth( " 当前状态 " ) );
  62. // ScrollBar( this->m_olist.GetSafeHwnd( ) );
  63. }//会议列表
  64. if( this->m_clist )
  65. {
  66. this->m_clist.SetExtendedStyle( LVS_EX_FULLROWSELECT );
  67. this->m_clist.InsertColumn( 0 , "会议名称" , LVCFMT_CENTER , this->m_clist.GetStringWidth( " 会议名称 " ) );
  68. this->m_clist.InsertColumn( 1 , "主持人" , LVCFMT_CENTER , this->m_clist.GetStringWidth( " 主持人 " ) );
  69. // ScrollBar( this->m_clist.GetSafeHwnd( ) );
  70. }//参与者列表
  71. if( this->m_rlist )
  72. {
  73. this->m_rlist.SetExtendedStyle( LVS_EX_FULLROWSELECT );
  74. this->m_rlist.InsertColumn( 0 , "参与者" , LVCFMT_CENTER , this->m_rlist.GetStringWidth( " 参与者 " ) );
  75. this->m_rlist.InsertColumn( 1 , "是否发言" , LVCFMT_CENTER , this->m_rlist.GetStringWidth( " 是否发言 " ) );
  76. // ScrollBar( this->m_rlist.GetSafeHwnd( ) );
  77. }//按钮图片
  78. this->m_btn1.SetBitmaps( IDB_BTN_SELECT_BITMAP , RGB( 255 , 255 , 255 ) , IDB_BTN_NORMAL_BITMAP , RGB( 255 , 255 , 255 ) );
  79. this->m_btn1.SetAlign( CButtonST::ST_ALIGN_OVERLAP );
  80. this->m_btn1.SetColor( CButtonST::BTNST_COLOR_BK_IN , RGB( 214 , 239 , 255 ) );
  81. this->m_btn1.SetColor( CButtonST::BTNST_COLOR_BK_OUT , RGB( 214 , 239 , 255 ) );
  82. this->m_btn1.SetColor( CButtonST::BTNST_COLOR_BK_FOCUS , RGB( 214 , 239 , 255 ) );
  83. this->m_btn1.DrawBorder( false );
  84.     //按钮图片
  85. this->m_btn2.SetBitmaps( IDB_BTN_SELECT_BITMAP , RGB( 255 , 255 , 255 ) , IDB_BTN_NORMAL_BITMAP , RGB( 255 , 255 , 255 ) );
  86. this->m_btn2.SetAlign( CButtonST::ST_ALIGN_OVERLAP );
  87. this->m_btn2.SetColor( CButtonST::BTNST_COLOR_BK_IN , RGB( 214 , 239 , 255 ) );
  88. this->m_btn2.SetColor( CButtonST::BTNST_COLOR_BK_OUT , RGB( 214 , 239 , 255 ) );
  89. this->m_btn2.SetColor( CButtonST::BTNST_COLOR_BK_FOCUS , RGB( 214 , 239 , 255 ) );
  90. this->m_btn2.DrawBorder( false );
  91. //默认情况为选定在线用户列表
  92. this->m_tab.SetCurSel( 0 );
  93. return TRUE; 
  94. }
  95. //窗口大小发生变化时
  96. void CConferenceDialog::OnSize(UINT nType, int cx, int cy) 
  97. {
  98. CDialog::OnSize(nType, cx, cy);
  99. if( this->m_tab )
  100. this->m_tab.MoveWindow( 0 , 0 , cx , cy );
  101. if( this->m_olist )
  102. this->m_olist.MoveWindow( 0 , 0 , cx , cy - 50 );
  103. if( this->m_clist )
  104. this->m_clist.MoveWindow( 0 , 0 , cx , cy - 50 );
  105. if( this->m_rlist )
  106. this->m_rlist.MoveWindow( 0 , 0 , cx , cy - 50 );
  107. if( this->m_btn1 )
  108. this->m_btn1.MoveWindow( 15 , cy - 50 , 71 , 25 );
  109. if( this->m_btn2 )
  110. this->m_btn2.MoveWindow( cx - 90 , cy - 50 , 71 , 25 );
  111. }
  112. //活动标签状态发生改变
  113. void CConferenceDialog::OnTab( void * pContext , int index , bool m_bShow )
  114. {
  115. CConferenceDialog * pThis = ( CConferenceDialog * )pContext;
  116. pThis->m_btn1.ShowWindow( SW_SHOW );
  117. pThis->m_btn2.ShowWindow( SW_SHOW );
  118. switch( index )
  119. {
  120. case 0 :
  121. {
  122. pThis->m_btn1.SetWindowText( "邀请用户" );
  123. // pThis->m_btn2.SetWindowText( "上课" );
  124. pThis->m_btn2.ShowWindow( SW_HIDE );
  125. }
  126. break;
  127. case 1 :
  128. {
  129. pThis->m_btn1.SetWindowText( "创建会议" );
  130. pThis->m_btn2.SetWindowText( "加入会议" );
  131. }
  132. break;
  133. case 2 :
  134. {
  135. pThis->m_btn1.SetWindowText( "退出会议" );
  136. pThis->m_btn2.SetWindowText( "申请发言" );
  137. pThis->OnItemchangedRecipientList( NULL , NULL );
  138. }
  139. break;
  140. }
  141. }
  142. BOOL CConferenceDialog::OnCommand(WPARAM wParam, LPARAM lParam) 
  143. {
  144. if( ! CDialog::OnCommand(wParam, lParam) )
  145. return this->GetParent( )->SendMessage( WM_COMMAND , wParam , lParam );
  146. return TRUE;
  147. }
  148. UINT CConferenceDialog::OnNcHitTest(CPoint point) 
  149. {
  150. UINT hitTest = CDialog::OnNcHitTest(point);
  151. return ( hitTest == HTCLIENT || hitTest == HTCAPTION ) ? HTTRANSPARENT : hitTest;
  152. }
  153. //会议成员列表选项发生改变
  154. void CConferenceDialog::OnItemchangedRecipientList(NMHDR* pNMHDR, LRESULT* pResult) 
  155. {
  156. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  157. if( pResult ) * pResult = 0;
  158. if( this->m_tab.GetCurSel( ) != 2 )
  159. return;
  160. CString szItem;
  161.     //如果是主持人
  162. if( theApp.GetClient( ).IsCharement( ) )
  163. {
  164. POSITION pos = this->m_rlist.GetFirstSelectedItemPosition( );
  165. if( pos )
  166. {
  167. int index = this->m_rlist.GetNextSelectedItem( pos );
  168. this->m_btn2.ShowWindow( this->m_rlist.GetItemData( index ) == theApp.GetClient( ).GetUserID( ) ? SW_HIDE : SW_SHOW );
  169. szItem = this->m_rlist.GetItemText( index , 1 );
  170. this->m_btn2.SetWindowText( szItem.Find( "是" ) != -1 ? "停止发言" : "点名发言" );
  171. }
  172. }
  173. else //如果不是主持人
  174. this->m_btn2.SetWindowText( theApp.GetClient( ).GetSoundIn( ).IsRecording( ) ? "停止发言" : "申请发言" );
  175. }
  176. //邀请用户
  177. void CConferenceDialog::OnDblclkOnlineList(NMHDR* pNMHDR, LRESULT* pResult) 
  178. {
  179. if( this->mainFrame )
  180. this->mainFrame->OnCreateConferenceButton( );
  181. *pResult = 0;
  182. }
  183. //加入会议
  184. void CConferenceDialog::OnDblclkConferenceList(NMHDR* pNMHDR, LRESULT* pResult) 
  185. {
  186. if( this->mainFrame )
  187. this->mainFrame->OnJoinConferenceButton( );
  188. *pResult = 0;
  189. }
  190. //点名发言
  191. void CConferenceDialog::OnDblclkRecipientList(NMHDR* pNMHDR, LRESULT* pResult) 
  192. {
  193. if( theApp.GetClient( ).IsCharement( ) && this->mainFrame )
  194. this->mainFrame->OnJoinConferenceButton( );
  195. *pResult = 0;
  196. }