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

ICQ/即时通讯

开发平台:

Visual C++

  1. // ChatLeft.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MSN.h"
  5. #include "ChatLeft.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CChatLeft dialog
  13. CChatLeft::CChatLeft(CWnd* pParent /*=NULL*/)
  14. : CDialog(CChatLeft::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CChatLeft)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void CChatLeft::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CChatLeft)
  24. DDX_Control(pDX, IDC_RICHEDIT_SEND, m_RichSend);
  25. DDX_Control(pDX, IDC_RICHEDIT_CHAT, m_RichChat);
  26. //DDX_Control(pDX, IDC_STATIC_TIP, m_tip);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CChatLeft, CDialog)
  30. //{{AFX_MSG_MAP(CChatLeft)
  31. ON_WM_ERASEBKGND()
  32. ON_WM_SIZE()
  33. ON_WM_PAINT()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CChatLeft message handlers
  38. BOOL CChatLeft::OnInitDialog() 
  39. {
  40. CDialog::OnInitDialog();
  41. CRect rcSplitter;
  42. CRect rect;
  43. GetClientRect(rect);
  44. CWnd* pWnd;
  45. pWnd = GetDlgItem(IDC_STATIC_SPLITTER);
  46. pWnd->GetWindowRect(rcSplitter);
  47. ScreenToClient(rcSplitter);
  48. m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, CRect(1,rcSplitter.top,rect.Width()-2,rcSplitter.bottom), this, IDC_STATIC_SPLITTER);
  49. m_wndSplitter.SetRange(50, rect.Height()-100);
  50. if (!m_wndToolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |WS_VISIBLE| CBRS_TOP | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  51. !m_wndToolbar.LoadToolBar(IDR_TOOLBAR1))
  52. {
  53. TRACE0("Failed to create toolbarn");
  54. return -1;      // fail to create
  55. }
  56. //SetWindowSkinResID(m_wndToolbar.m_hWnd, 999); 
  57. //SetDialogEraseBkgnd(m_hWnd);
  58. return TRUE; 
  59. }
  60. LRESULT CChatLeft::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  61. {
  62. if (message == WM_NOTIFY)
  63. {
  64. if (wParam == IDC_STATIC_SPLITTER)
  65. {
  66. SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
  67. DoResize(pHdr->delta);
  68. }
  69. }
  70. return CDialog::DefWindowProc(message, wParam, lParam);
  71. }
  72. void CChatLeft::DoResize(int delta)
  73. {
  74. CRect rect;
  75. GetClientRect(rect);
  76. int cx = rect.Width();
  77. int cy = rect.Height();
  78. CRect rcSplitter;
  79. //CStatic *tic = (CStatic*)GetDlgItem(IDC_STATIC_TIP);
  80. //if (tic==NULL)
  81. //{
  82. //tic->MoveWindow(1,1,cx-2,20);
  83. //return;
  84. //}
  85. m_wndSplitter.GetWindowRect(rcSplitter);
  86. ScreenToClient(rcSplitter);
  87. CEdit  *rich = (CEdit*)GetDlgItem(IDC_RICHEDIT_CHAT);
  88. rich->MoveWindow(CRect(0,0,cx,rcSplitter.top));
  89. m_wndToolbar.MoveWindow(0,rcSplitter.bottom,cx,27);
  90. m_RichSend.MoveWindow(CRect(0, rcSplitter.bottom + 27, cx, rect.Height()));
  91. //m_BtnSender.MoveWindow(cx-75,rcSplitter.bottom+28,70,50);
  92. Invalidate();
  93. }
  94. void CChatLeft::OnSize(UINT nType, int cx, int cy)
  95. {
  96. CDialog::OnSize(nType, cx, cy);
  97. if (m_RichSend.m_hWnd==NULL)
  98. return;
  99. CRect rcSplitter;
  100. CRect rectRichSender;
  101. m_wndSplitter.GetWindowRect(rcSplitter);
  102. m_RichSend.GetWindowRect(rectRichSender);
  103. m_RichSend.MoveWindow(CRect( 0, cy - rectRichSender.Height(), cx , cy));
  104. m_wndToolbar.MoveWindow(0,cy - rectRichSender.Height()-27,cx, 27);
  105. m_wndSplitter.MoveWindow(1,cy - rectRichSender.Height()-27-rcSplitter.Height(),cx-2, rcSplitter.Height());
  106. m_RichChat.MoveWindow(CRect(0,0,cx,cy - rectRichSender.Height()-27-rcSplitter.Height()));
  107. //m_tip.MoveWindow(20,1,cx-22,22);
  108. // m_BtnSender.MoveWindow(cx-75,cy - rectRichSender.Height()+2,70,50);
  109. m_wndSplitter.SetRange(50, cy-100);
  110. //Invalidate();
  111. }