messageview.cpp
来自「一个简易的聊天室程序」· C++ 代码 · 共 107 行
CPP
107 行
// MessageView.cpp : implementation file
//
#include "stdafx.h"
#include "ChatClient.h"
#include "MessageView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMessageView
IMPLEMENT_DYNCREATE(CMessageView, CEditView)
CMessageView::CMessageView()
{
}
CMessageView::~CMessageView()
{
}
BEGIN_MESSAGE_MAP(CMessageView, CEditView)
//{{AFX_MSG_MAP(CMessageView)
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMessageView drawing
void CMessageView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CMessageView diagnostics
#ifdef _DEBUG
void CMessageView::AssertValid() const
{
CEditView::AssertValid();
}
void CMessageView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMessageView message handlers
void CMessageView::Message(LPCTSTR lpszMessage)
{
CString strTemp = lpszMessage;
strTemp += _T("\r\n");
int len = GetWindowTextLength();
GetEditCtrl().SetSel(len,len);
GetEditCtrl().ReplaceSel(strTemp);
}
BOOL CMessageView::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 CMessageView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
return;
CEditView::OnChar(nChar, nRepCnt, nFlags);
}
void CMessageView::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
LOGFONT lf; // Used to create the CFont.
memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.
lf.lfHeight = 16; // Request a 20-pixel-high font
strcpy(lf.lfFaceName, "Verdana"); // with face name "Arial".
m_font.CreateFontIndirect(&lf); // Create the font.
SetFont(&m_font);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?