inputview.cpp

来自「利用CSocket类编写的一个网络聊天程序,加深对CSocket类的基本应用的认」· C++ 代码 · 共 93 行

CPP
93
字号
// 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);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?