richeditctrlex.cpp

来自「Visual C++网络游戏建模与实现(第2版)」· C++ 代码 · 共 83 行

CPP
83
字号
// richeditctrlex.cpp : implementation file
//

#include "stdafx.h"
#include "..\gamehigh.h"
#include "..\include\richeditctrlex.h"
#include "macros.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRichEditCtrlEx

CRichEditCtrlEx::CRichEditCtrlEx()
{
}

CRichEditCtrlEx::~CRichEditCtrlEx()
{
}


BEGIN_MESSAGE_MAP(CRichEditCtrlEx, CRichEditCtrl)
	//{{AFX_MSG_MAP(CRichEditCtrlEx)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRichEditCtrlEx message handlers

BOOL CRichEditCtrlEx::AppendText(LPCTSTR lpszText, COLORREF clrText)
{
	ASSERT(lpszText);
	if(NULL == lpszText ||
		0 == strlen(lpszText))
	{
		return FALSE;
	}

	SAFE_CHECKWND(this)
	{
		CHARFORMAT   CharFormat;
		memset(&CharFormat,0,sizeof(CHARFORMAT));
		
		CharFormat.cbSize=sizeof(CHARFORMAT);
		CharFormat.dwMask=CFM_COLOR;
		CharFormat.crTextColor=clrText;
		this->SetWordCharFormat(CharFormat);

		this->ReplaceSel(lpszText, FALSE);
	}
	return TRUE;
}

BOOL CRichEditCtrlEx::AppendText(LPCTSTR lpszText, int nHeight, COLORREF clrText)
{
	ASSERT(lpszText);
	if(NULL == lpszText ||
		0 == strlen(lpszText))
	{
		return FALSE;
	}

	SAFE_CHECKWND(this)
	{
		CHARFORMAT   CharFormat;
		memset(&CharFormat,0,sizeof(CHARFORMAT));
		
		CharFormat.cbSize		=sizeof(CHARFORMAT);
		CharFormat.dwMask		=CFM_COLOR | CFM_SIZE;
		CharFormat.crTextColor	=clrText;
		CharFormat.yHeight		=nHeight;
		this->SetWordCharFormat(CharFormat);

		this->ReplaceSel(lpszText, FALSE);
	}
	return TRUE;
}

⌨️ 快捷键说明

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