1. Technology

Get the RTF formatting from a RichEdit

By

Here's how to get the pure RTF formatted text from a TRichEdit control.

Usage: Memo1.Text := GetRTF(RichEdit1) ;

~~~~~~~~~~~~~~~~~~~~~~~~~
function GetRTF(RE: TRichedit): string;
var
   strStream: TStringStream;
begin
   strStream := TStringStream.Create('') ;
   try
     RE.PlainText := False;
     RE.Lines.SaveToStream(strStream) ;
     Result := strStream.DataString;
   finally
     strStream.Free
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to place a progress bar inside a standard dialog box
« What's the word under the mouse cursor in a TRichEdit?

©2014 About.com. All rights reserved.