当我尝试使用
RichEdit1.Lines.LoadFromFile(FilePath)
方法和 RichEdit1.ReadOnly = True
加载 RTF 文件时,RichEdit 会从 RTF 文件中删除所有图像并在其位置显示一个空白区域:
procedure TForm1.Button1Click(Sender: TObject);
var
BasePath: String;
FilePath: String;
begin
GetDir(0, BasePath);
FilePath := BasePath + '\TestRtfFileMS.Rtf';
RichEdit1.Lines.LoadFromFile(FilePath);
RichEdit2.ReadOnly := True;
RichEdit2.Lines.LoadFromFile(FilePath);
end;
我该如何解决这个问题?
我解决如下。
首先,在“word”中写入包含图像的*.rtf文件。 (不应该写在写字板中。)
在运行时,rtf 文件被导入到 RichEdit 中并设置为 RayOnly = True。
RichEdit1.Lines.LoadFromFile('myFile.rtf'); RichEdit1.ReadOnly := True;