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


// InputView.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ChatClient.h" 
#include "InputView.h" 
#include "ChatClientDoc.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CInputView 
 
IMPLEMENT_DYNCREATE(CInputView, CEditView) 
 
CInputView::CInputView() 
{ 
} 
 
CInputView::~CInputView() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CInputView, CEditView) 
	//{{AFX_MSG_MAP(CInputView) 
	ON_WM_CHAR() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CInputView drawing 
 
void CInputView::OnDraw(CDC* pDC) 
{ 
	CDocument* pDoc = GetDocument(); 
	// TODO: add draw code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CInputView diagnostics 
 
#ifdef _DEBUG 
void CInputView::AssertValid() const 
{ 
	CEditView::AssertValid(); 
} 
 
void CInputView::Dump(CDumpContext& dc) const 
{ 
	CEditView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CInputView message handlers 
BOOL CInputView::PreCreateWindow(CREATESTRUCT& cs)  
{ 
	BOOL ret = CEditView::PreCreateWindow(cs); 
	cs.style = AFX_WS_DEFAULT_VIEW |  
		       WS_VSCROLL |  
               ES_AUTOVSCROLL |  
			   ES_MULTILINE |  
			   ES_NOHIDESEL; 
	return ret; 
} 
 
void CInputView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if (nChar != VK_RETURN) 
	{ 
		CEditView::OnChar(nChar, nRepCnt, nFlags); 
		return; 
	} 
	else 
	{ 
		CChatClientDoc* pDoc = (CChatClientDoc*)m_pDocument; 
		CString strText; 
		GetEditCtrl().GetWindowText(strText); 
		//作为普通消息发送 
		pDoc->SendMsg(strText, 4, true); 
		strText=_T(""); 
		GetEditCtrl().SetWindowText(strText); 
		GetEditCtrl().SetSel(9,9,FALSE); 
	} 
	CEditView::OnChar(nChar, nRepCnt, nFlags); 
}