从Delphi中的richedit获取richtext

Tim*_*Tim 4 delphi richedit delphi-2007

有没有办法从richedit获取RTF数据而不使用savetostream

strStream := TStringStream.Create('') ;
try
  RichEdit.Lines.SaveToStream(strStream);
  Text := strStream.DataString;
  strStream.CleanupInstance;
finally
  strStream.Free
Run Code Online (Sandbox Code Playgroud)

RRU*_*RUZ 5

Tim从RichEdit控件获取RTF数据的唯一方法是使用Stream,因为EM_STREAMOUT检索RTF数据的windows message()需要一个EditStreamCallback结构,这是windows用于将rtf数据传入或传出richedit控件的方式.

因此,您可以使用自己的示例代码,或实现对Windows消息的调用EM_STREAMOUT.