ChatLeft.cpp
资源名称:MSN.rar [点击查看]
上传用户:seeker_wen
上传日期:2016-05-23
资源大小:2084k
文件大小:4k
源码类别:
ICQ/即时通讯
开发平台:
Visual C++
- // ChatLeft.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MSN.h"
- #include "ChatLeft.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CChatLeft dialog
- CChatLeft::CChatLeft(CWnd* pParent /*=NULL*/)
- : CDialog(CChatLeft::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CChatLeft)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CChatLeft::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CChatLeft)
- DDX_Control(pDX, IDC_RICHEDIT_SEND, m_RichSend);
- DDX_Control(pDX, IDC_RICHEDIT_CHAT, m_RichChat);
- //DDX_Control(pDX, IDC_STATIC_TIP, m_tip);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CChatLeft, CDialog)
- //{{AFX_MSG_MAP(CChatLeft)
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChatLeft message handlers
- BOOL CChatLeft::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CRect rcSplitter;
- CRect rect;
- GetClientRect(rect);
- CWnd* pWnd;
- pWnd = GetDlgItem(IDC_STATIC_SPLITTER);
- pWnd->GetWindowRect(rcSplitter);
- ScreenToClient(rcSplitter);
- m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, CRect(1,rcSplitter.top,rect.Width()-2,rcSplitter.bottom), this, IDC_STATIC_SPLITTER);
- m_wndSplitter.SetRange(50, rect.Height()-100);
- if (!m_wndToolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |WS_VISIBLE| CBRS_TOP | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolbar.LoadToolBar(IDR_TOOLBAR1))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- //SetWindowSkinResID(m_wndToolbar.m_hWnd, 999);
- //SetDialogEraseBkgnd(m_hWnd);
- return TRUE;
- }
- LRESULT CChatLeft::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if (message == WM_NOTIFY)
- {
- if (wParam == IDC_STATIC_SPLITTER)
- {
- SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
- DoResize(pHdr->delta);
- }
- }
- return CDialog::DefWindowProc(message, wParam, lParam);
- }
- void CChatLeft::DoResize(int delta)
- {
- CRect rect;
- GetClientRect(rect);
- int cx = rect.Width();
- int cy = rect.Height();
- CRect rcSplitter;
- //CStatic *tic = (CStatic*)GetDlgItem(IDC_STATIC_TIP);
- //if (tic==NULL)
- //{
- //tic->MoveWindow(1,1,cx-2,20);
- //return;
- //}
- m_wndSplitter.GetWindowRect(rcSplitter);
- ScreenToClient(rcSplitter);
- CEdit *rich = (CEdit*)GetDlgItem(IDC_RICHEDIT_CHAT);
- rich->MoveWindow(CRect(0,0,cx,rcSplitter.top));
- m_wndToolbar.MoveWindow(0,rcSplitter.bottom,cx,27);
- m_RichSend.MoveWindow(CRect(0, rcSplitter.bottom + 27, cx, rect.Height()));
- //m_BtnSender.MoveWindow(cx-75,rcSplitter.bottom+28,70,50);
- Invalidate();
- }
- void CChatLeft::OnSize(UINT nType, int cx, int cy)
- {
- CDialog::OnSize(nType, cx, cy);
- if (m_RichSend.m_hWnd==NULL)
- return;
- CRect rcSplitter;
- CRect rectRichSender;
- m_wndSplitter.GetWindowRect(rcSplitter);
- m_RichSend.GetWindowRect(rectRichSender);
- m_RichSend.MoveWindow(CRect( 0, cy - rectRichSender.Height(), cx , cy));
- m_wndToolbar.MoveWindow(0,cy - rectRichSender.Height()-27,cx, 27);
- m_wndSplitter.MoveWindow(1,cy - rectRichSender.Height()-27-rcSplitter.Height(),cx-2, rcSplitter.Height());
- m_RichChat.MoveWindow(CRect(0,0,cx,cy - rectRichSender.Height()-27-rcSplitter.Height()));
- //m_tip.MoveWindow(20,1,cx-22,22);
- // m_BtnSender.MoveWindow(cx-75,cy - rectRichSender.Height()+2,70,50);
- m_wndSplitter.SetRange(50, cy-100);
- //Invalidate();
- }