是否为TRichEditViewer导入外部RTF文件? [英] Import external RTF file for TRichEditViewer?

查看:155
本文介绍了是否为TRichEditViewer导入外部RTF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Inno Setup脚本的自定义页面上使用TRichEditViewer.是否可以将外部RTF文件读入变量,然后将该变量用作查看器的内容?还是我必须在脚本中保留实际的RTF代码?

I'm using TRichEditViewer on a custom page in an Inno Setup script. Is it possible to read an external RTF file into a variable, and use that variable as the content of the viewer? Or do I have to keep the actual RTF code in the script?

非常感谢收到任何帮助.

Any help gratefully received.

推荐答案

您应该能够使用LoadStringFromFileRTF文件读取为字符串.从Inno 文档:

You should be able to use LoadStringFromFile to read an RTF file into a string. From the Inno documentation:

原型:

函数 LoadStringFromFile (常量FileName:字符串; var S:AnsiString):布尔值;

function LoadStringFromFile(const FileName: String; var S: AnsiString): Boolean;

说明:

将指定的二进制或非Unicode文本文件加载到指定的字符串中.如果成功,则返回True,否则返回False.

Loads the specified binary or non Unicode text file into the specified string. Returns True if successful, False otherwise.

您应该能够使用类似以下内容的 ANSI Inno Setup 定义string类型变量或 Unicode Inno Setup AnsiString类型变量:

You should be able to define a string type variable for ANSI Inno Setup or AnsiString type variable for Unicode Inno Setup using something like:

var
#ifndef UNICODE
  rtfstr: string;
#else
  rtfstr: AnsiString;
#endif

然后输入代码:

LoadStringFromFile('filenamehere.rtf', rtfstr);

然后使用类似于下面的代码.在此示例中,假定oRichViewerTRichEditViewer对象:

And then use code similar to what is below. In this example assume oRichViewer is a TRichEditViewer object:

oRichViewer.UseRichEdit := True;
oRichViewer.RTFText := rtfstr;

这应该具有将我们先前从文件中加载的rtfstr放入TRichEditViewer的作用.

This should have the effect of putting rtfstr which we loaded from the file earlier into the TRichEditViewer .

这篇关于是否为TRichEditViewer导入外部RTF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆