www.pudn.com > 3.rar > ChatView.cpp


// ChatView.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ChatServer.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; 
	 
	// TODO: Add your specialized creation code here 
	CRect rect; 
	GetClientRect(&rect); 
	m_EditBox.Create(WS_VISIBLE | 
		             WS_BORDER | 
					 WS_CHILD | 
					 ES_MULTILINE | 
					 WS_VSCROLL, 
					 rect, this , 0); 
	return 0; 
} 
 
void CChatView::OnSize(UINT nType, int cx, int cy)  
{ 
	CView::OnSize(nType, cx, cy); 
	 
	// TODO: Add your message handler code here 
	m_EditBox.MoveWindow(0 , 0 , cx , cy , FALSE); 
} 
 
void CChatView::ShowMessage(LPCTSTR lpszMessage) 
{ 
	CString strTemp = lpszMessage; 
	strTemp += _T("\r\n"); 
	int len = m_EditBox.GetWindowTextLength(); 
	m_EditBox.SetSel(len,len); 
	m_EditBox.ReplaceSel(strTemp); 
}