Advanced RichEditCtrl | CodeGuru

Advanced RichEditCtrl

There are two main classes CRTFBuilder responsible for all RTF building CRichEditCtrlEx, which simply derives from CRichEditCtrl and adds a few methods RTFBuilder starts off with 1 font and 4 colors: Arial, Black, Red, Green Blue Methods: black, red, blue, green turns text to the specified color color Takes a COLORREF and turns the text […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 16, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

There are two main classes
CRTFBuilder responsible for all RTF building
CRichEditCtrlEx, which simply derives from CRichEditCtrl and adds a few methods


RTFBuilder starts off with 1 font and 4 colors:

Arial,
Black,
Red,
Green
Blue


Methods:

black, red, blue, green turns text to the specified color
color Takes a COLORREF and turns the text that color
font Changes the font. Takes a font name as a string
size Takes an integer as the font size
bold(bool) Turns text bold
italic(bool) italic
underline(bool) underline
strike(bool) strike through
normal turns off the above 4 settings
push pushes the current settings on it’s own stack
pull pulls the last settings from the stack
write Takes a CRichEditCtrl as a parameter and writes to that control. Can also use the ‘>>’ operator (see example)

RichEditCtrlEx simply derives fron CRichEditCtrl and adds a few methods

enable(bool)

disable(bool)

It also overrides PreSubclassWindow to turn the background color to that
of the dialog(button) color to give the appearance of a simple lable and
sets the control to read only.

The export declarations in the ‘RichEd’ header make it possible to compile RichEditCtrlEx.cpp in either
a library of MFC extension DLL.

The ‘RichEd’ project is the library and the ‘test’ project is an example dialog based exe project.
To get going, simply compile and run.

Download demo project/source – 21 KB

Date Posted: 08.08.98

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.