Using rich text in an application

Rich text format (RTF) is a standard for specifying formatting instructions and document content in a single ASCII document. An editor that supports rich text format interprets the formatting instructions and displays the text with formatting.

In an application, you may want to:

  • Provide a window for preparing rich text documents

    Although not a full-fledged word processor, the RichTextEdit control allows the user to apply formatting to paragraphs, words, and characters.

  • Create a mail-merge application

    You or the user can set up boilerplate text with input fields associated with database data.

  • Display reports with formatted text

    A RichText DataWindow object is designed for viewing data, rather than entering data. It does not have the edit styles of other DataWindow presentation styles.

  • Store rich text as a string in a database and display it in a RichTextEdit control

Sources of rich text

Any word processor

You can prepare rich text in any word processor that can save or export rich text format.

Input fields in PowerBuilder applications only

Although many word processors support some kinds of fields, the fields are usually incompatible with other rich text interpreters. If you want to specify input fields for a PowerBuilder application, you will have to insert them using the PowerBuilder RichTextEdit control.

Rich text in the database

Since rich text is represented by ASCII characters, you can also store rich text in a string database column or string variable. You can retrieve rich text from a string database column and use the PasteRTF function to display the text with formatting in a RichTextEdit control.

Language of rich text

English is the currently recommended language for the rich text, as only English is fully tested. The other languages will be listed here after they are fully tested in the future versions.

Rich text editors

You can select from the rich text editors supported by PowerBuilder. The selected rich text editor will be applicable to the RichTextEdit control, the RichText DataWindow object, and the RichText edit style. For how to select the rich text editor, see the section called “Specifying a rich text editor” in Users Guide.

  • For 32-bit application, select Built-in TX Text Control ActiveX.

  • For 64-bit application, select Built-in TX Text Control ActiveX or Microsoft RichEdit Control.

Built-in TX Text Control ActiveX is a special OEM version of TX Text Control ActiveX; it is provided at no cost and is highly recommended to be used by all existing PowerBuilder projects.

There are feature differences between the two 64-bit editors: Feature difference between TX Text Control (64-bit) and Microsoft RichEdit Control (64-bit).

Feature difference between TX Text Control (64-bit) and Microsoft RichEdit Control (64-bit)

If you intended to build a 64-bit application, it is recommended to select Built-in TX Text Control ActiveX (32-bit and 64-bit) which is used as the rich text editor by both 32-bit and 64-bit applications; otherwise, Microsoft RichEdit Control will be used as the 64-bit rich text editor by the 64-bit application.

Pay attention to the following differences between TX Text Control (64-bit) and Microsoft RichEdit Control (64-bit).

Microsoft RichEdit Control (64-bit) TX Text Control (64-bit)

The UI is old fashioned and not updated for long time.

The UI is more modern and user friendly.

The font and size in the toolbar does not display at initial launch.

The font and size in the toolbar display at initial launch.

RichText DataWindows cannot successfully retrieve data.

RichText DataWindows can successfully retrieve data.

The SaveAs of RichText DataWindows only supports save to PDF in Distill! Method, and the method must be specified before save.

The SaveAs of RichText DataWindows supports save to PDF in Distill! or NativePDF! method. NativePDF! method will be used if none is specified.

The RMB menu of RichTextEdit control and RichText DataWindow only supports inserting files of RTF and TXT formats.

The InsertDocument and SaveDocument functions of RichTextEdit control only support files of RTF and TXT formats.

Therefore,

InsertDocument ("*.htm",true) returns -1

InsertDocument("*.doc",true) returns -1

SaveDocument (string f, {FileTypeDoc!|FileTypeHTML!|FileTypePDF!}) returns -1 and FileExists event is not triggered.

The RMB menu of RichTextEdit control and RichText DataWindow supports inserting files of RTF/TXT/DOC/DOCX/HTML formats.

The InsertDocument function of RichTextEdit control supports files of RTF/TXT/DOC/DOCX/HTML formats.

The SaveDocument function of RichTextEdit control supports files of RTF/TXT/DOC/DOCX/HTML/PDF formats and can trigger the FileExists event correctly.

If the document inserted into RichTextEdit control and RichText DataWindow contains tables, tables will not display.

If the document inserted into RichTextEdit control and RichText DataWindow contains tables, tables can display.

The RMB menu of RichTextEdit control and RichText DataWindow supports 4 RichText presentation settings: Input Fields Names Visible, Returns Visible, Tabs Visible and Spaces Visible.

The RMB menu of RichTextEdit control and RichText DataWindow supports 3 RichText presentation settings: Input Fields Names Visible, ControlChars Visible (covering Returns Visible, Tabs Visible and Spaces Visible), and Input Fields Visible.

RichTextEdit control and RichText DataWindow do not support the status bar property.

RichTextEdit control and RichText DataWindow support the status bar property.

When locating the footer through ShowHeadFoot, Position returns the header (which is incorrect); when locating the footer manually, Position returns the correct value.

When locating the footer through ShowHeadFoot or manually, Position returns the correct value.

The footer and header areas of RichTextEdit control and RichText DataWindow cannot display at the same time as the main content area, unless you call ShowHeaderFooter(true).

The footer and header areas of RichTextEdit control and RichText DataWindow can display at the same time as the main content area.

Mouse wheel does not scroll a RichTextEdit page.

Mouse wheel can scroll a RichTextEdit page.

The preview mode of RichTextEdit control and RichText DataWindow is more like a print preview, for example, the left side will show the paper size/margin/page information, and the margin and page settings can be dynamically modified.

In preview mode of RichTextEdit control and RichText DataWindow, the left side does not show the paper size/margin/page information.


Deploying a rich text application

To deploy an application that uses the built-in text editor, you can use the PowerBuilder Runtime Packager to deploy the required rich text files with your application.

For more information on the runtime packager, see PowerBuilder Runtime Packager.