ShowBroadcastDlg.cpp
上传用户:guangzhiyw
上传日期:2007-01-09
资源大小:495k
文件大小:6k
源码类别:

ICQ/即时通讯

开发平台:

Visual C++

  1. // ShowBroadcastDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "client.h"
  5. #include "ShowBroadcastDlg.h"
  6. #include "FriendDetail.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CShowBroadcastDlg dialog
  14. CShowBroadcastDlg::CShowBroadcastDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CShowBroadcastDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CShowBroadcastDlg)
  18. m_strDate = _T("");
  19. m_strEmail = _T("");
  20. m_strID = _T("");
  21. m_strName = _T("");
  22. m_strTime = _T("");
  23. //}}AFX_DATA_INIT
  24. hIcon=AfxGetApp()->LoadIcon(IDR_MESSAGE);
  25. pDetailDlg=NULL;
  26. pInfo=NULL;
  27. m_bClose=TRUE;
  28. }
  29. void CShowBroadcastDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CShowBroadcastDlg)
  33. DDX_Control(pDX, ID_SHOW_DETAIL, m_headbmp);
  34. DDX_Control(pDX, IDC_TALK, m_EditMsg);
  35. DDX_Control(pDX, IDC_HISTORY, m_EditRecord);
  36. DDX_Text(pDX, IDC_DATE, m_strDate);
  37. DDX_Text(pDX, IDC_EMAIL, m_strEmail);
  38. DDX_Text(pDX, IDC_ID, m_strID);
  39. DDX_Text(pDX, IDC_NAME, m_strName);
  40. DDX_Text(pDX, IDC_TIME, m_strTime);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CShowBroadcastDlg, CDialog)
  44. //{{AFX_MSG_MAP(CShowBroadcastDlg)
  45. ON_BN_CLICKED(ID_NEXT, OnNext)
  46. ON_BN_CLICKED(ID_SHOW_HISTORY, OnShowHistory)
  47. ON_BN_CLICKED(ID_SHOW_DETAIL, OnShowDetail)
  48. ON_WM_CLOSE()
  49. //}}AFX_MSG_MAP
  50. ON_MESSAGE(WM_SHOW_NOTICE,OnShowNotice)
  51. ON_MESSAGE(WM_REFRESH_DATA,OnRefreshData)
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CShowBroadcastDlg message handlers
  55. BOOL CShowBroadcastDlg::OnInitDialog() 
  56. {
  57. CDialog::OnInitDialog();
  58. SetIcon(hIcon,TRUE);
  59. SetIcon(hIcon,FALSE);
  60. CMenu* pMenu=GetSystemMenu(FALSE);
  61. pMenu->EnableMenuItem(SC_RESTORE,MF_GRAYED|MF_DISABLED);
  62. pMenu->EnableMenuItem(SC_SIZE,MF_GRAYED|MF_DISABLED);
  63. pMenu->EnableMenuItem(SC_MAXIMIZE,MF_GRAYED|MF_DISABLED);
  64. CRect r1,r2;
  65. GetWindowRect(&r1);
  66. m_EditRecord.GetWindowRect(&r2);
  67. r1.SetRect(r1.left,r1.top,r1.right,r2.top);
  68. MoveWindow(r1);
  69. return TRUE; 
  70. }
  71. void CShowBroadcastDlg::OnNext() 
  72. {
  73. SaveMsg * pMsg=GetApp()->m_aNoticeMsg.GetAt(GetApp()->m_nCurNotice);
  74. if(GetApp()->m_aNoticeMsg.GetSize()>GetApp()->m_nCurNotice)
  75. {
  76. memset(&Info,0,sizeof(Info));
  77. Info.Id=pMsg->ID;
  78. Info.HaveDetail=0;
  79. UserInfo * pInfo=NULL;
  80. m_strID.Format("%d",pMsg->ID);
  81. int photoid=0;
  82. if((FindInArray(GetApp()->m_aUserInfo,pMsg->ID,pInfo)||FindInArray(GetApp()->m_aStranger,pMsg->ID,pInfo))&&pInfo->HaveDetail)
  83. {
  84. m_strEmail=pInfo->Email;
  85. m_strName=pInfo->Name;
  86. if(pInfo->PhotoId>=0&&pInfo->PhotoId<UINT(GetApp()->m_nNumberHeadBmp))
  87. photoid=pInfo->PhotoId;
  88. }
  89. else
  90. {
  91. m_strEmail="";
  92. m_strName="";
  93. pInfo=&Info;
  94. }
  95. CBitmap* pBmp=NULL;
  96. pBmp=GetApp()->m_paBitmap[2*photoid];
  97. m_headbmp.SetBitmap(pBmp);
  98. m_strDate=pMsg->Time.Format(" %Y-%m-%d");
  99. m_strTime=pMsg->Time.Format(" %H:%M:%S");
  100. m_EditMsg.SetWindowText(pMsg->Msg);
  101. GetApp()->m_nCurNotice++;
  102. if(GetApp()->m_aNoticeMsg.GetSize()>GetApp()->m_nCurNotice)
  103. GetDlgItem(ID_NEXT)->EnableWindow();
  104. else
  105. GetDlgItem(ID_NEXT)->EnableWindow(FALSE);
  106. UpdateData(FALSE);
  107. }
  108. void CShowBroadcastDlg::OnShowHistory() 
  109. {
  110. static BOOL bShowRecord=TRUE;
  111. CRect r1,r2;
  112. GetWindowRect(&r1);
  113. m_EditRecord.GetWindowRect(&r2);
  114. if(bShowRecord)
  115. r1.SetRect(r1.left,r1.top,r1.right,r2.bottom+4);
  116. else
  117. r1.SetRect(r1.left,r1.top,r1.right,r2.top);
  118. bShowRecord=!bShowRecord;
  119. MoveWindow(r1);  
  120. }
  121. void CShowBroadcastDlg::OnShowDetail() 
  122. {
  123. if(pDetailDlg==NULL)
  124. {
  125. pDetailDlg=new CFriendDetailDlg;
  126. pDetailDlg->Create(CFriendDetailDlg::IDD,GetDesktopWindow());
  127. }
  128. pDetailDlg->SetOwnerWnd(this);
  129. pDetailDlg->SendMessage(WM_SHOW_FRIEND_DETAIL,(WPARAM)pInfo,0);
  130. pDetailDlg->OnRefresh();
  131. }
  132. LRESULT CShowBroadcastDlg::OnShowNotice(WPARAM wParam,LPARAM lParam)
  133. {
  134. CString str;
  135. SaveMsg *pMsgNew=GetApp()->m_aNoticeMsg.GetAt(GetApp()->m_aNoticeMsg.GetSize()-1);
  136. str.Format("(%s)%drn%srnrn",pMsgNew->Time.Format("%Y-%m-%d %H:%M:%S"),pMsgNew->ID,pMsgNew->Msg);
  137. m_EditRecord.SetSel(0,0);
  138. m_EditRecord.ReplaceSel(str);
  139. SaveMsg* pMsg=GetApp()->m_aNoticeMsg.GetAt(GetApp()->m_nCurNotice);
  140. if(m_bClose)
  141. {
  142. memset(&Info,0,sizeof(Info));
  143. Info.Id=pMsg->ID;
  144. Info.HaveDetail=0;
  145. m_strID.Format("%d",pMsg->ID);
  146. int photoid=0;
  147. if((FindInArray(GetApp()->m_aUserInfo,pMsg->ID,pInfo)||FindInArray(GetApp()->m_aStranger,pMsg->ID,pInfo))&&pInfo->HaveDetail)
  148. {
  149. m_strEmail=pInfo->Email;
  150. m_strName=pInfo->Name;
  151. if(pInfo->PhotoId>=0&&pInfo->PhotoId<UINT(GetApp()->m_nNumberHeadBmp))
  152. photoid=pInfo->PhotoId;
  153. }
  154. else
  155. {
  156. m_strEmail="";
  157. m_strName="";
  158. pInfo=&Info;
  159. }
  160. m_headbmp.SetBitmap(GetApp()->m_paBitmap[2*photoid]);
  161. m_strDate=pMsg->Time.Format(" %Y-%m-%d");
  162. m_strTime=pMsg->Time.Format(" %H:%M:%S");
  163. m_EditMsg.SetWindowText(pMsg->Msg);
  164. GetApp()->m_nCurNotice++;
  165. if(GetApp()->m_aNoticeMsg.GetSize()>GetApp()->m_nCurNotice)
  166. GetDlgItem(ID_NEXT)->EnableWindow();
  167. else
  168. GetDlgItem(ID_NEXT)->EnableWindow(FALSE);
  169. UpdateData(FALSE);
  170. m_bClose=FALSE;
  171. }
  172. else
  173. {
  174. if(GetApp()->m_aNoticeMsg.GetSize()>GetApp()->m_nCurNotice)
  175. GetDlgItem(ID_NEXT)->EnableWindow();
  176. }
  177. ShowWindow(SW_SHOWNORMAL);
  178. return 0;
  179. }
  180. void CShowBroadcastDlg::OnCancel() 
  181. {
  182. m_bClose=TRUE;
  183. CDialog::OnCancel();
  184. }
  185. void CShowBroadcastDlg::OnOK()
  186. {
  187. OnCancel();
  188. }
  189. void CShowBroadcastDlg::OnClose() 
  190. {
  191. OnCancel();
  192. }
  193. LRESULT CShowBroadcastDlg::OnRefreshData(WPARAM wParam,LPARAM lParam)
  194. {
  195. m_strName=pInfo->Name;
  196. m_strEmail=pInfo->Email;
  197. if(pInfo->PhotoId>=0&&pInfo->PhotoId<UINT(GetApp()->m_nNumberHeadBmp))
  198. m_headbmp.SetBitmap(GetApp()->m_paBitmap[2*pInfo->PhotoId]);
  199. UpdateData(FALSE);
  200. return 1;
  201. }