Board index » delphi » RichEdit RTF Text

RichEdit RTF Text

Is there a way I can get the _formatted_ text of a richedit control into a
string. My ultimate goal is to be able to save and restore the text and
formatting of a rich edit control without using files. Basicly I have a
server on the other side of a network that needs to set/store the rich text
as part of a welcome/splash screen. The text will change from time to time
and my store/retrieval routines look like this:

procedure SetMemo (Key:String[20], Buffer:array[0..1999] of char);
procedure GetMemo (Key:String[20],var Buffer:array[0..1999] of char);

Unfortunately I really cant change these routines very much. I just need a
way to get the text _AND_ the formatting into that array of char. Most of my
server routines are this way, and I am making use of the Move command a lot.

Any assistance is greatly appreciated.

Richard Carruthers

 

Re:RichEdit RTF Text


In <38d7a5ad@dnews>, "Notta Chance" hastily scribbled:

Quote

> Is there a way I can get the _formatted_ text of a richedit control into a
> string. My ultimate goal is to be able to save and restore the text and
> formatting of a rich edit control without using files. Basicly I have a
> server on the other side of a network that needs to set/store the rich text
> as part of a welcome/splash screen. The text will change from time to time
> and my store/retrieval routines look like this:

> procedure SetMemo (Key:String[20], Buffer:array[0..1999] of char);
> procedure GetMemo (Key:String[20],var Buffer:array[0..1999] of char);

> Unfortunately I really cant change these routines very much. I just need a
> way to get the text _AND_ the formatting into that array of char. Most of my
> server routines are this way, and I am making use of the Move command a lot.

Use RichEdit.Lines.SaveToStream to place the formatted rich text into a TMemoryStream. Once there, you can move it into your array of char quite easily.

Roger Morton
roger.mor...@dial.pipex.com

Re:RichEdit RTF Text


Quote
In article <38d7a5ad@dnews>, Notta Chance wrote:
> Is there a way I can get the _formatted_ text of a richedit control into a
> string.

Easy <g>:

  Function GetRawRTFText( aRichedit: TRichedit ): String;
  var
    SS: TStringstream;
  begin
    SS:= TStringstream.Create( EmptyStr );
    try
      aRichedit.plaintext := False;
      arichedit.Lines.SaveToStream( SS );
      Result := SS.DataString;
    finally
      SS.Free
    end;
  end;

Untested!  

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads