chatviewre.cpp
来自「一个简易的聊天室程序」· C++ 代码 · 共 115 行
CPP
115 行
// ChatViewRE.cpp : implementation file
//
#include "stdafx.h"
//#include "chatclient.h"
#include "ChatViewRE.h"
#include "ChatClientDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include <afxrich.h>
/////////////////////////////////////////////////////////////////////////////
// CChatViewRE
IMPLEMENT_DYNCREATE(CChatViewRE, CRichEditView)
CChatViewRE::CChatViewRE()
{
}
CChatViewRE::~CChatViewRE()
{
}
BEGIN_MESSAGE_MAP(CChatViewRE, CRichEditView)
//{{AFX_MSG_MAP(CChatViewRE)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChatViewRE drawing
void CChatViewRE::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CChatViewRE diagnostics
#ifdef _DEBUG
void CChatViewRE::AssertValid() const
{
CRichEditView::AssertValid();
}
void CChatViewRE::Dump(CDumpContext& dc) const
{
CRichEditView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChatViewRE message handlers
void CChatViewRE::OnInitialUpdate()
{
CRichEditView::OnInitialUpdate();
GetRichEditCtrl().SetReadOnly(TRUE);
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask =
CFM_BOLD|
// CFM_ITALIC|
// CFM_UNDERLINE|
// CFM_STRIKEOUT|
CFM_SIZE|
CFM_COLOR;
// CFM_OFFSET|
// CFM_PROTECTED;
cf.dwEffects = CFE_AUTOCOLOR | FW_NORMAL;
cf.yHeight = 200; //10pt
// cf.wWeight = FW_NORMAL;
cf.yOffset = 0;
cf.crTextColor = RGB(0, 0, 0);
cf.bCharSet = 0;
cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
strcpy(cf.szFaceName, "Arial");
cf.dwMask |= CFM_FACE;
GetRichEditCtrl().SetDefaultCharFormat(cf);
}
void CChatViewRE::message(LPCTSTR lpszMessage, CHARFORMAT cf)
{
CString strTemp = lpszMessage;
strTemp += _T("\r\n");
int len = GetWindowTextLength();
GetRichEditCtrl().SetSel(len, len);
GetRichEditCtrl().SetSelectionCharFormat(cf);
GetRichEditCtrl().ReplaceSel(strTemp);
}
CHARFORMAT CChatViewRE::GetCharFormat()
{
CHARFORMAT cf;
this->GetRichEditCtrl().GetSelectionCharFormat(cf);
return cf;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?