PC SOFT

WINDEV的在线文档

  • The RTF format
  • Edit control in RTF format
  • Notes
  • RTF format support
  • Defining the initial content of an RTF edit control
  • Writing into an RTF edit control by programming (by using the RTF attributes)
  • Using the text attributes in an RTF Edit control
  • Saving a text in a RTF file
  • Saving a text in RTF format in an item of a HFSQL file
  • Performing a "Find/Replace" operation in an edit control in RTF format
  • Handling the characters in an edit control in RTF format
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

The RTF format
The RTF (Rich Text Format) is used to code the text and the graphics specifically in order to facilitate their transfer from an application to another one.

The RTF is a "tagged" format. Indeed, specific tags are used to specify the style of each word, group of words or sentences found in the text in RTF.

WinDev allows you to handle text in RTF format via the "RTF format" option of edit controls and static controls.

16版本和更高版本
You also have the ability to use ..管理RTF to modify the RTF type of a control by programming.
16新版本
You also have the ability to use ..管理RTF to modify the RTF type of a control by programming.
You also have the ability to use ..管理RTF to modify the RTF type of a control by programming.

  • If the text in RTF format is displayed in a control that does not support the RTF format, the tags will be displayed.
  • If the text in RTF format is displayed in a control that supports the RTF format, the tags will be automatically interpreted and the text will be formatted accordingly.
Note: To use an edit control in RTF format, the "RICHED20.DLL" file must be found on the current computer. In most cases, the "RICHED20.DLL" file is found in the system directory of Windows. If a later version of the RTF control is available on the computer (including the RTF 4.1 control installed with Windows XP Service Pack 1), this version is used.

Edit control in RTF format
An RTF edit control is used to display a text in RTF format and to enter a text in RTF format.

When entering a text in an RTF control, this text is in RTF format. This text contains all the tags required to format the RTF.

Notes

  • WinDev You have the ability to display a formatting toolbar above the RTF control. This toolbar allows the user to easily format the RTF text entered. See RTF formatting toolbar for more details.
  • WinDev For the applications that operate in Windows Vista (or later) or in Tablet PC, you have the ability to include the "Handwritten input" option. This option allows the user to directly enter the text in the control with the stylus or with the mouse. This feature is available by default in the applications that operate on Mobile.
  • If the same text is entered in a standard edit control and in an RTF edit control, the character string found in the RTF edit control will be longer than the string found in the standard edit control (because the RTF tags are added).
  • The RTF edit control supports basic RTF formatting, so it can be used on any platform. The specific characters such as the page breaks, the notes, ... are not supported.

RTF format support

The format of the RTF files supported is the same RTF format as the one supported by "Wordpad" (up to Windows XP).

If the RTF file is generated by another tool (Word, ...), we advise you to open the file in Wordpad in order to check the RTF compatibility. The display of the file in Wordpad will provide a better preview of what will be printed.

In all cases, we recommend that you re-save the file in Wordpad to force the format of RTF.

Note: You can also force the RTF format directly with WinDev or WebDev. To do so, RTF加载数据 must be used to assign the RTF control.

Defining the initial content of an RTF edit control
To define the initial content of an RTF edit control (solution 1):
  1. Display the "Content" tab of the description of the RTF edit control.
  2. Enter the content of the RTF control in the "Initial content" field. To format the text, display the formatting toolbar via the "RTF formatting toolbar" option found in the popup menu of the "Initial content" control.
  3. Validate the description window.

To define the initial content of a RTF edit control (solution 2):
  1. Enter your text and format it via any RTF editor (Word, WinDev document editor, ...)
  2. Copy this text (Ctrl C).
  3. Display the "Content" tab of the description of the RTF edit control.
  4. Paste the RTF text. The text is displayed with its formatting.

Writing into an RTF edit control by programming (by using the RTF attributes)
WinDevWindows

Using the text attributes in an RTF Edit control

To use text attributes in an edit control in RTF format, you must:
  • select the text in the edit control. The text selected by the user is highlighted by default. To select a text, you have the ability to use ..光标 and ..光标结束 for example.
  • use RTF选定数据. This function is used to find out and modify the RTF attributes (bold, ...) of a selection.
Example: Applying the bold attribute to the selected text

The following code, placed in the exit code of an RTF edit control, is used to apply the bold attribute to the selected text.

如果EDT_Edit1..光标结束大于EDT_Edit1..光标,那么
RTF选定数据EDT_Edit1RTF.粗体
结束

Saving a text in a RTF file
WinDevWindows In an RTF edit control, the text is automatically entered in RTF format.

To save the content of an edit control in RTF format in a RTF file, you must:

  1. Create the RTF file (文件创建) or open an existing RTF file (RTF加载数据).
  2. Copy the content of the RTF control into the current file (文件写).

Example: Creating a "MyDoc.RTF" file. This file contains the text entered in the edit control named TEXT_RTF.

sFileName字符串型
sMyString字符串型
nFileID整数型
sFileName文件选择器"""""Select a file...",...
"RTF files"+TAB+"*.RTF"+回车+"All files (*.*)"+TAB+"*.*",...
"RTF"文件选择器.创建+文件选择器.存在
nFileID文件打开sFileName文件打开.不存在则创建+文件打开.添加+文件打开.读写
如果nFileID=-1,那么
错误"The file opening failed"
否则
// Fill the string to write into the file
sMyStringEDT_Edit1
// Write the block
文件写nFileIDsMyString
// Close the file
文件关闭nFileID
结束

WinDevWindows

Saving a text in RTF format in an item of a HFSQL file

To save a text in RTF format in a file item, we recommend you link the edit control to a Text Memo item.

Indeed, as the RTF format includes several tags, a "Character string" item is usually not large enough.

Performing a "Find/Replace" operation in an edit control in RTF format
WinDevWindows To perform a Search/Replace operation in an RTF text:
  1. Use RTF查找数据 to find the requested text in the edit control in RTF format.
  2. Replace the text with RTF替换数据.

Example: Finding WinDev 5 and replacing it by WinDev 19.

n整数型
sSoughtWord字符串型"WinDev 5"
sWordReplace字符串型"WinDev 19"
// Case-insensitive search, starting from the end of selection
nRTF查找数据EDT_Edit1sSoughtWord
// If the word is found
如果n-1,那么
// Replaces the word found
RTF替换数据EDT_Edit1sReplaceWordnn+长度sSoughtWord))
结束

Handling the characters in an edit control in RTF format
WinDevWindows WinDev also allows you to handle the characters found in a string or in a RTF control. Some examples:

Example: Limiting/Truncating the number of characters found in a RTF string (excluding the RTF tags).

// Truncates the RTF to the number of characters specified in MaxNbChar
nMaxNbCharacters整数型
nMaxNbCharacters3
RTF替换数据EDT_RTF_Text""nMaxNbCharacters+1长度EDT_RTF_Text))

Example: Calculate the number of characters found int a RTF string (excluding the RTF tags).

// Retrieves the RTF content without formatting
sUnicodeUNICODE字符串型
nNbCharacters整数型

sUnicodeRTF转换到文本EDT_RTF_Text
nNbCharacters长度sUnicode
信息nNbCharacters