CopyRTF

Description

Returns the selected text, pictures, and input fields in a RichTextEdit control or RichText DataWindow as a string with rich text formatting. Bitmaps and input fields are included in the string.

Applies to

DataWindow controls, DataStore objects, and RichTextEdit controls

Syntax

rtename.CopyRTF ( { selected {, band } } )

Argument

Description

rtename

The name of the DataWindow control, DataStore object, or RichTextEdit control from which you want to copy the selection in rich text format. The DataWindow object in the DataWindow control or DataStore must be a RichText DataWindow.

selected (optional)

A boolean value indicated whether to copy selected text only. Values are:

  • TRUE -- (Default) Copy selected text only

  • FALSE -- Copy the entire contents of the band

band (optional)

A value of the Band enumerated datatype specifying the band from which to copy text. Values are:

  • Detail! -- Copy text from the detail band

  • Header! -- Copy text from the header band

  • Footer! -- Copy text from the footer band

The default is the band that contains the insertion point.


Return value

String.

Returns the selected text as a string.

CopyRTF returns an empty string ("") if:

  • There is no selection and selected is true

  • An error occurs

Usage

CopyRTF does not involve the clipboard. The copied information is stored in a string. If you use the standard clipboard functions (Copy and Cut) the clipboard will contain the text without any formatting.

To incorporate the text with RTF formatting into another RichTextEdit control, use PasteRTF. For more information about rich text format, see the chapter about implementing rich text in Application Techniques.

Examples

This statement returns the text that is selected in the RichTextEdit rte_message and stores it in the string ls_richtext:

string ls_richtext
ls_richtext = rte_message.CopyRTF()

This example copies the text in rte_1, saving it in ls_richtext, and pastes it into rte_2. The user clicks the RadioButton rb_true to copy selected text and rb_false to copy all the text. The number of characters pasted is saved in ll_numchars reported in the StaticText st_status:

string ls_richtext
boolean lb_selected
long ll_numchars
 
IF rb_true.Checked = TRUE THEN
      lb_selected = TRUE
ELSE
      lb_selected = FALSE
END IF
 
ls_richtext = rte_1.CopyRTF(lb_selected)
ll_numchars = rte_2.PasteRTF(ls_richtext)
st_status.Text = String(ll_numchars)

See also

PasteRTF