delphi从TRichEdit获得RTF格式文本(PC版本)

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;


procedure TForm1.Button1Click(Sender: TObject);
begin
RichEdit1.Lines.LoadFromFile('e:\123.rtf');
Memo1.Text := GetRTF(RichEdit1);
end;

 

procedure TForm1.Button2Click(Sender: TObject);
begin
RichEdit1.Lines.LoadFromFile('e:\123.rtf');
Memo1.Lines.Assign(RichEdit1.Lines);
end;

 

posted on 2019-03-11 11:21  疯狂delphi  阅读(1031)  评论(1编辑  收藏  举报

导航