PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • The RTF format
  • Edit control in RTF format
  • Notes
  • Supported RTF format
  • Defining the initial content of an RTF edit control
  • Colors in Pocket PC
  • Writing into an RTF edit control by programming (by using the RTF attributes)
  • Using the text attributes in an edit control in RTF format
  • Saving a text in an 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
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.
Versions 16 and later
You also have the ability to use ..RichEdit to modify the RTF type of a control by programming.
New in version 16
You also have the ability to use ..RichEdit to modify the RTF type of a control by programming.
You also have the ability to use ..RichEdit 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

  • Windows Mobile The RTF control is used to display and enter a RTF text. However, the formatting of the text cannot be modified.
  • 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 type 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.

Supported RTF format

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 also have the ability to force the RTF format with WINDEV or WEBDEV. To do so, RTFLoad 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 an RTF edit control (solution 2):
  1. Type 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.
Windows Mobile

Colors in Pocket PC

On the non-VGA Pocket PCs, only the primary colors are supported. The other columns are displayed in black.
Writing into an RTF edit control by programming (by using the RTF attributes)
WINDEVWindows

Using the text attributes in an edit control in RTF format

To use the 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 ..Cursor and ..CursorEnd for example.
  • use RTFSelection. 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.
IF EDT_Edit1..CursorEnd > EDT_Edit1..Cursor THEN
        RTFSélection(EDT_Edit1, rtfBold, True)
END
Saving a text in an 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 (fCreate) or open an existing RTF file (RTFLoad).
  2. Copy the content of the RTF file into the current file (fWrite).
Example: Creating a "MyDoc.RTF" file. This file contains the text entered in the edit control named TEXT_RTF.
sFileName is string
sMyString is string
nFileID is int
sFileName = fSelect("", "", "Select a file...", ...
"RTF files" + TAB + "*.RTF" + CR + "All files (*.*)" + TAB + "*.*", ...
"RTF", fselCreate + fselExist)
nFileID = fOpen(sFileName, foCreateIfNotExist + foAdd + foReadWrite)
IF nFileID = -1 THEN
Error("The file opening failed")
ELSE
// Fill the string to write into the file
sMyString = EDT_Edit1
// Write the block
fWrite(nFileID, sMyString)
// Close the file
fClose(nFileID)
END
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 "Find/Replace" operation in a text in RTF format:
  1. Use RTFSearch to find the requested text in the edit control in RTF format.
  2. Replace the text with RTFReplace.
Example: Finding WINDEV 5 and replacing it by WINDEV 19.
n is int
sSoughtWord is string = "WinDev 5"
sWordReplace is string = "WinDev 19"
// Case-insensitive search, starting from the end of selection
n = RTFSearch(EDT_Edit1, sSoughtWord)
// If the word is found
IF n-1 THEN
// Replaces the word found
RTFReplace(EDT_Edit1, sReplaceWord, n, n + Length(sSoughtWord))
END
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 an 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 is int
nMaxNbCharacters = 3
RTFReplace(EDT_RTF_Text, "", nMaxNbCharacters + 1, Length(EDT_RTF_Text))
Example: Calculating the number of characters found in an RTF string (excluding the RTF tags).
// Retrieves the RTF content without formatting
sUnicode is UNICODE string
nNbCharacters is int

sUnicode = RTFToText(EDT_RTF_Text)
nNbCharacters = Length(sUnicode)
Info(nNbCharacters)
Related Examples:
The RTF edit control Unit examples (WINDEV Mobile): The RTF edit control
[ + ] Using text in RTF format in the edit controls.
This format is very useful to format and view data.
Management of RTF Unit examples (WINDEV): Management of RTF
[ + ] Using the main functions for RTF management in a WINDEV application:
- Load a file in RTF format
- Save a file in RTF format
- Find and select a word in an RTF text
- Display a text in RTF format
- Modify the characteristics of a selection (font, case, color, ...)
The special characters Unit examples (WINDEV): The special characters
[ + ] Handling special characters in an RTF control and viewing the ASCII and ANSI codes.
Switching from the RTF format to the HTML format Unit examples (WINDEV): Switching from the RTF format to the HTML format
[ + ] Using RTFToHTML and RTFToText.
WD Sending faxes Sample components (WINDEV): WD Sending faxes
[ + ] This example is using the WINDEV SendingFaxes component.

This component is used to send a FAX typed in text or RTF format.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment