rvico TRichView Reference | Item Types

Controls

Top  Previous  Next

You can insert any Delphi/C++Builder control in the document.

Style of this item type: rvsComponent (-5)

Additional Properties

This item type has the following specific extra integer properties:

rvepSpacing spacing around the control;
rvepResizable allows resizing;
rvepVisible allows to hide the control (to set its Visible property to False).

This item type has the following properties affecting vertical position:

VAlign;
extra properties: rvepVShift, rvepVShiftAbs.

Vertical Position

This item type has the following properties affecting vertical position:

VAlign;
extra integer properties: rvepVShift, rvepVShiftAbs.

Resizing

You can allow resizing this control in editor by assigning non-zero value to its rvepResizable extra property.

You can forbid mouse resizing of all images and controls in the editor by including rvoNoImageResize in EditorOptions.

Resizing with mouse changes Width and Height properties of the control.

Resizing is activated if this control is selected. You can select this control (for example, in its OnClick event) by calling RichView.SelectControl.

OnItemResize event occurs after resizing.

Methods of TCustomRichView

The following viewer-style methods add item of this type to the end of the document:

AddControlEx,
AddControlExTag

The following viewer-style method changes the main properties of item of this type:

SetControlInfo

The following method returns main properties of the given item of this type:

GetControlInfo

See also

FindControlItemNo

Methods of TCustomRichViewEdit

The following editor-style method inserts item of this type at the position of caret:

InsertControl

The following editor-style methods modify main properties of the item of this type:

SetCurrentControlInfo,
SetControlInfoEd

The following method returns main properties of the item of this type at the position of caret:

GetCurrentControlInfo

Also

ResizeControl,
ResizeCurrentControl,
AdjustControlPlacement2

Events:

OnControlAction occurs when the control is loaded from RVF, deleted, moved to/from undo buffer, saved to RVF.

Memory Usage

RichView owns this control, and it will destroy it when clearing document. Do not free memory for controls inserted in RichView yourself. Do not insert the same control twice.

Note about Tags of controls

RichView uses tags of inserted controls (TComponent.Tag) for its own needs. Please do not use and do not modify tags of controls.

(this note is about Tag property of component, not about tags of items; you can use item's tag as you wish)

Saving and Loading

RVF

In order to load these items from RVF, you need to register a class of the control.

For example:

Delphi: RegisterClass(TButton);
C++Builder: RegisterClass(__classid(TButton));

If rvfoSaveControlsBody is excluded from RVFOptions, control itself is not saved in RVF. When loading such RVF files, OnRVFControlNeeded event occurs.

Export to text, RTF, and HTML

By default, controls are not exported. Use OnSaveComponentToFile event to save controls.

Printing

RichView creates a temporal bitmap, draws the control in it, then prints this bitmap.

It's not possible to create an universal procedure for drawing all possible controls. If you are not satisfied with the results, override the default printing with OnPrintComponent event.

Special Width Mode

Width of controls can be set in percent:

var Item: TRVControlItemInfo

  ...

Item := RichView.GetItem(ItemNo) as TRVControlItemInfo;

Item.PercentWidth := 50; // 50% of document width (minus paragraph indents)

The effect will be after reformatting.

See also...

BeginOleDrag


RichView © Sergey Tkachenko