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 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



Comments

  • How can you use this class in a DOC/VIEW

    Posted by Legacy on 08/20/2003 12:00am

    Originally posted by: Tom Hill

    Hi
    I Already Use in Doc/View by do following:
    I Creat my project with name CTestRichView which inherit from CviewEditCtrl you should see in step 6 of MFC widzard
    Then int function CTestRichViewView::OnInitialUpdate()
    you should insert:
    CRichEditCtrl &theRich=this->GetRichEditCtrl();
    CRTFBuilder b ;
    b << size ( 35 )
    << bold(true)
    << color( 1 )
    << "The Title\n"
    << write( theRich ) ;


    You remember include RichEditCtrlEx.h and Link file Lib
    Hope you success
    googbye

    Reply
  • Nice RichText Programming!

    Posted by Legacy on 04/23/2003 12:00am

    Originally posted by: Laser Park

    Thank you!
    
    Apply my job!

    Reply
  • [Re] VC6 errors

    Posted by Legacy on 03/07/2003 12:00am

    Originally posted by: Young Su, Cha

    try to do like this;

    for(iterator i=begin(); i!=end(); i++)
    -> for(const_iterator i = begin( ) ; i!=end( ) ; i++)

    ..

    Reply
  • compiler error in VC6

    Posted by Legacy on 09/21/2002 12:00am

    Originally posted by: tjie

    there are error:
    
    

    ichEditCtrlEx.cpp
    F:\visual C++\Edit\richeditctrlex\RichEditCtrlEx.h(103) : error C2440: 'initializing' : cannot convert from 'class std::list<class CString,class std::allocator<class CString> >::const_iterator' to 'class std::list<class CString,class std::allocator<
    class CString> >::iterator'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    F:\visual C++\Edit\richeditctrlex\RichEditCtrlEx.h(103) : error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'class std::list<class CString,class std::allocator<class CString> >::iterator' (or there is no acceptab
    le conversion)
    Error executing cl.exe.

    Reply
  • need to extract bold text alone in rtf control in vb

    Posted by Legacy on 01/24/2002 12:00am

    Originally posted by: vikram

    hi all
    
    i was able to select a text and make it bold, now i want store the content in a file,the problem is that i want the text that was bold to be stored in the file with the tag <bold>, is it possible to find the text that has been made bold in rich text box control,
    thank you in advance

    Reply
  • How to make it work with Unicode

    Posted by Legacy on 12/14/2001 12:00am

    Originally posted by: Hope

    This is a great project. But if I change project setting to have _UNICODE and recompiled, nothing was put out to the two edit window.
    Please help to get it work with Unicode.

    Thanks a million!!

    Hope

    Reply
  • Help about CRichEditCtrl in Windows 2000

    Posted by Legacy on 11/09/2001 12:00am

    Originally posted by: Ignacio Garcia

    In my application, i use a CRitchEditCtrl to show a text. I change the char type between Arial to Symbol, and i do it with the method SetSelectionCharFormat. But Windows 2000 don't change the char type because don't untherstand this method. I would like to know what can i do, if i have to use a library, or header file or if i need a compiler more actual. Thank you and sorry because my English is very bad.

    Reply
  • need help: dealing with mouse in a richeditctrl

    Posted by Legacy on 07/04/2001 12:00am

    Originally posted by: sabine

    I need some help in dealing with this richeditctrl.
    i want to get any message or make any change when I click on the richeditctrl.
    I need some more help on the "CRichEditDtrl::FindText" function. I always get (-1) as its return value, eventhough the text i'm looking for is shown in the richeditctrl.
    I will be so greatful if anyone could help!

    Reply
  • Need Help about Win Sockets

    Posted by Legacy on 12/18/2000 12:00am

    Originally posted by: Junaid

    i m developing urdu chat server for Lan's
    anybody to help in sockets

    Reply
  • Column (Block) Marking by Alt + Left-Mouse-Down-Drag

    Posted by Legacy on 05/23/2000 12:00am

    Originally posted by: basava

    Hello,

    We need to implement this column marking in a rich-edit-ctrl. This feature is available in many editors - Msdev, MsWord etc. You can select a vertical block by dragging left-Mouse-down with Alt key pressed. You can cut, copy, delete or paste the column-marked selection. It is very useful feature in any edit control.

    Can anyone tell me how to enable this feature for rich-edit-control or how can it be implemented?

    Thanks
    Basava.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds