www.gusucode.com > VC++三子棋游戏源码(类似五子棋)-源码程序 > VC++三子棋游戏源码(类似五子棋)-源码程序\code\Client\chatview.cpp
//Download by http://www.NewXing.com // chatview.cpp : implementation file // #include "stdafx.h" #include "SanQi.h" #include "chatview.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CChatView IMPLEMENT_DYNCREATE(CChatView, CView) CChatView::CChatView() { } CChatView::~CChatView() { } BEGIN_MESSAGE_MAP(CChatView, CView) //{{AFX_MSG_MAP(CChatView) ON_WM_CREATE() ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CChatView drawing void CChatView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CChatView diagnostics #ifdef _DEBUG void CChatView::AssertValid() const { CView::AssertValid(); } void CChatView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CChatView message handlers int CChatView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) { return -1; } int nMaxPos = MAXLONG; // this->SetScrollRange(SB_VERT, 0, 20000); m_wndBtmDlgBar.Create(this); AfxInitRichEdit(); RECT rect; memset(&rect, 0, sizeof(RECT)); m_ChatRichEdit.Create(ES_LEFT|ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL | WS_CHILD|WS_VISIBLE|ES_READONLY|ES_WANTRETURN, rect,this,0); CWnd* pWnd =&m_ChatRichEdit; SAFE_CHECKWND(pWnd) { COLORREF clrBk =RGB(150, 175, 230); m_ChatRichEdit.SetBackgroundColor(FALSE, clrBk); //m_ChatRichEdit.SetReadOnly(TRUE); m_ChatRichEdit.AppendText("- 按 <Ctrl+C> 可以 Copy 你选择的内容! -\n\n", RGB(128, 0, 255)); } return 0; } void CChatView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); int iHeight = 0; { CWnd* pWnd =&m_wndBtmDlgBar; SAFE_CHECKWND(pWnd) { RECT rect,rt; memset(&rect, 0, sizeof(RECT)); this->GetClientRect(&rect); pWnd->GetClientRect(&rt); rect.top =rect.bottom - 40; //40--Bottom Dlg Bar Height pWnd->MoveWindow(&rect); pWnd->GetClientRect(&rt); iHeight = rt.bottom-rt.top; } } { CWnd* pWnd =&m_ChatRichEdit; SAFE_CHECKWND(pWnd) { RECT rect; memset(&rect, 0, sizeof(RECT)); this->GetClientRect(&rect); rect.bottom = rect.top+(rect.bottom-iHeight-4); m_ChatRichEdit.MoveWindow(&rect); } } } void CChatView::ShowChatMessage(CString strSender, CString strChatMessage) { CString strDetailInfo(""); strDetailInfo.Format("[%s] 说: ",strSender); m_ChatRichEdit.AppendText(strDetailInfo, RGB(128, 0, 128)); m_ChatRichEdit.AppendText(strChatMessage+"\n", RGB(0, 0, 0)); }