Get richtext from a richedit in Delphi

Tim picture Tim · Sep 3, 2010 · Viewed 8.7k times · Source

Is there a way to get the RTF data from a richedit without using savetostream as in

strStream := TStringStream.Create('') ;
try
  RichEdit.Lines.SaveToStream(strStream);
  Text := strStream.DataString;
  strStream.CleanupInstance;
finally
  strStream.Free

Answer

RRUZ picture RRUZ · Sep 3, 2010

Tim the only way to get the RTF data from an RichEdit control is using a Stream because the windows message (EM_STREAMOUT) wich retrieve the RTF Data require a EditStreamCallback structure, this is the way used by windows to transfer rtf data into or out of a richedit control.

So you can use your own sample code, or implement the call to the windows message EM_STREAMOUT.