UserChat.cpp
上传用户:seeker_wen
上传日期:2016-05-23
资源大小:2084k
文件大小:5k
源码类别:

ICQ/即时通讯

开发平台:

Visual C++

  1. // UserChat.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MSN.h"
  5. #include "UserChat.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CUserChat dialog
  13. CUserChat::CUserChat(CWnd* pParent /*=NULL*/)
  14. : CDialog(CUserChat::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CUserChat)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void CUserChat::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CUserChat)
  24. DDX_Control(pDX, IDC_BUTTON_SWITCH, m_SwitchButton);
  25. DDX_Control(pDX, IDC_BUTTON_SEND, m_BtnSender);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CUserChat, CDialog)
  29. //{{AFX_MSG_MAP(CUserChat)
  30. ON_WM_SIZE()
  31. ON_WM_NCCREATE()
  32. ON_BN_CLICKED(IDC_BUTTON_SWITCH, OnButtonSwitch)
  33. ON_WM_ERASEBKGND()
  34. ON_WM_GETMINMAXINFO()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CUserChat message handlers
  39. BOOL CUserChat::OnInitDialog() 
  40. {
  41. CDialog::OnInitDialog();
  42. CRect rect;
  43. GetClientRect(rect);
  44. m_right.Create(IDD_CHAT_RIGHT,this);
  45. m_right.ShowWindow(SW_NORMAL);
  46. m_right.MoveWindow(rect.Width()-140,57,120,rect.Height()-85-19);
  47. CRect rcRight;
  48. m_right.GetClientRect(rcRight);
  49. m_left.Create(IDD_CHAT_LEFT,this);
  50. m_left.ShowWindow(SW_NORMAL);
  51. m_left.MoveWindow(7,57,rect.Width()-35-rcRight.Width(),rect.Height()-85-19);
  52. m_SwitchButton.MoveWindow(rect.Width()-12,57,12,31);
  53. CButton *btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND);
  54. SetWindowSkinResID(btn->m_hWnd, 500);
  55. btn->MoveWindow(rect.Width()-245, rect.Height()-40, 69, 21);
  56. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND2);
  57. SetWindowSkinResID(btn->m_hWnd, 501);
  58. btn->MoveWindow(rect.Width()-171, rect.Height()-40, 23, 21);
  59. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND3);
  60. btn->MoveWindow(7, rect.bottom-48, 51, 23);
  61. CStatic *tic = (CStatic *)GetDlgItem(IDC_STATICAD);
  62. tic->GetClientRect(rcRight);
  63. tic->MoveWindow(9, rect.Height()-12, rcRight.Width(), rcRight.Height());
  64. return TRUE; 
  65. }
  66. void CUserChat::OnSize(UINT nType, int cx, int cy) 
  67. {
  68. CDialog::OnSize(nType, cx, cy);
  69. if (m_right.m_hWnd==NULL)
  70. return;
  71. if (isOpen)
  72. {
  73. m_right.MoveWindow(cx-140,57,120,cy-85-19);
  74. CRect rcRight;
  75. m_right.GetClientRect(rcRight);
  76. m_left.MoveWindow(7,57,cx-35-rcRight.Width(),cy-85-19);
  77. CButton *btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND);
  78. btn->MoveWindow(cx-245, cy-40, 69, 21);
  79. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND2);
  80. btn->MoveWindow(cx-171, cy-40, 23, 21);
  81. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND3);
  82. btn->MoveWindow(7, cy-48, 51, 23);
  83. }
  84. else
  85. {
  86. m_right.MoveWindow(cx-140,57,0,cy-85-19);
  87. CRect rcRight;
  88. m_right.GetClientRect(rcRight);
  89. m_left.MoveWindow(7,57,cx-30,cy-85-19);
  90. CButton *btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND);
  91. btn->MoveWindow(cx-120, cy-40, 69, 21);
  92. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND2);
  93. btn->MoveWindow(cx-46, cy-40, 23, 21);
  94. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND3);
  95. btn->MoveWindow(7, cy-48, 51, 23);
  96. }
  97. CRect rcRight;
  98. CStatic *tic = (CStatic *)GetDlgItem(IDC_STATICAD);
  99. tic->GetClientRect(rcRight);
  100. tic->MoveWindow(9, cy-12, cx, cy);
  101. m_SwitchButton.MoveWindow(cx-12,57,12,31);
  102. Invalidate();
  103. }
  104. BOOL CUserChat::OnNcCreate(LPCREATESTRUCT lpCreateStruct) 
  105. {
  106. if (!CDialog::OnNcCreate(lpCreateStruct))
  107. return FALSE;
  108. SetWindowSkinResID(m_hWnd, 999);
  109. return TRUE;
  110. }
  111. void CUserChat::OnButtonSwitch() 
  112. {
  113. isOpen = !isOpen;
  114. CRect rect;
  115. GetClientRect(rect);
  116. int cx = rect.Width();
  117. int cy = rect.Height();
  118. if (isOpen)
  119. {
  120. m_right.MoveWindow(cx-140,57,120,cy-85-19);
  121. CRect rcRight;
  122. m_right.GetClientRect(rcRight);
  123. m_left.MoveWindow(7,57,cx-35-rcRight.Width(),cy-85-19);
  124. CButton *btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND);
  125. btn->MoveWindow(cx-245, cy-40, 69, 21);
  126. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND2);
  127. btn->MoveWindow(cx-171, cy-40, 23, 21);
  128. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND3);
  129. btn->MoveWindow(7, cy-48, 51, 23);
  130. }
  131. else
  132. {
  133. m_right.MoveWindow(cx-140,57,0,cy-85-19);
  134. CRect rcRight;
  135. m_right.GetClientRect(rcRight);
  136. m_left.MoveWindow(7,57,cx-30,cy-85-19);
  137. CButton *btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND);
  138. btn->MoveWindow(cx-120, cy-40, 69, 21);
  139. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND2);
  140. btn->MoveWindow(cx-46, cy-40, 23, 21);
  141. btn = (CButton *)GetDlgItem(IDC_BUTTON_SEND3);
  142. btn->MoveWindow(7, cy-48, 51, 23);
  143. }
  144. m_SwitchButton.MoveWindow(cx-12,57,12,31);
  145. }
  146. BOOL CUserChat::OnEraseBkgnd(CDC* pDC) 
  147. {
  148. //CRect rc;
  149. //GetClientRect(rc);
  150. //DrawSkinImageRes(pDC->m_hDC, rc, "chat.bmp", 35, 35, 82, 14, FALSE);
  151. return TRUE;
  152. return CDialog::OnEraseBkgnd(pDC);
  153. }
  154. void CUserChat::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
  155. {
  156. lpMMI->ptMinTrackSize.x = 400;//   m_MinSize为最小尺寸   
  157. lpMMI->ptMinTrackSize.y = 415;//   m_MinSize为最小尺寸  
  158. CDialog::OnGetMinMaxInfo(lpMMI);
  159. }