为什么 TRichEdit 在 TRichEdit.ReadOnly 时从加载的文件中删除图像?

问题描述 投票:0回答:1

当我尝试使用

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;

我该如何解决这个问题?

delphi vcl trichedit
1个回答
0
投票

我解决如下。

  1. 首先,在“word”中写入包含图像的*.rtf文件。 (不应该写在写字板中。)

  2. 在运行时,rtf 文件被导入到 RichEdit 中并设置为 RayOnly = True。

    RichEdit1.Lines.LoadFromFile('myFile.rtf'); RichEdit1.ReadOnly := True;

© www.soinside.com 2019 - 2024. All rights reserved.