www.pudn.com > ChatSystem_src.zip > InputView.cpp
// InputView.cpp : implementation file
//
#include "stdafx.h"
#include "ChatClient.h"
#include "InputView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define NORMAL_MESSAGE 5
/////////////////////////////////////////////////////////////////////////////
// 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);
}
CChatClientDoc* CInputView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CChatClientDoc)));
return (CChatClientDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CInputView message handlers
BOOL CInputView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
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) || (nRepCnt!=1))
{
CEditView::OnChar(nChar, nRepCnt, nFlags);
return;
}
else
{
CChatClientDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CString strText;
GetEditCtrl().GetWindowText(strText);
pDoc->SendMsg(strText, NORMAL_MESSAGE, true);
strText=_T("");
GetEditCtrl().SetWindowText(strText);
GetEditCtrl().SetSel(9,9,FALSE);
}
}