RichView Format (RVF) Overview
RVF (RichView Format) is a file format specially designed for saving/loading TRichView documents. It is quite simple and compact format. It can be text file or binary file (defined by RichView.RVFOptions).
This format is used:
▪RVF can be copied to the Clipboard; editor can paste RVF;
▪data can be dragged&dropped as RVF;
All TRichVew document features can be saved in RVF. Collections of text, paragraph, list styles,style templates, margins and background can be saved optionally (see below).
▪main settings affecting RVF saving and loading can be changed in the TRichView component editor;
▪you can save pictures and controls in RVF, or create them on request when loading;
▪if you load controls in RVF you need to register their classes with RegisterClasses procedure (for example: RegisterClasses([TButton]));
▪the same for pictures; however, if picture class is not registered, TRichView will try to find the proper graphic class basing on content;
When loading, RichView needs to know which ImageList to use for the given bullet or hotspot. It asks the application about it by calling OnRVFImageListNeeded event. You need to process this event if you want to load bullets and hotspots.
If you have two ImageLists (ImageList1 and ImageList2) that you use for bullets in MyRichView, you can:
▪set ImageList1.Tag to 1, set ImageList2.Tag to 2,
▪process MyRichView.OnImageListNeeded event::
Sender: TCustomRichView; ImageListTag: Integer;
var il: TCustomImageList);
case ImageListTag of
il := ImageList1;
il := ImageList2;
DO NOT CONFUSE IMAGELIST.TAG WITH RICHVIEW ITEMS' TAGS. IN THIS CASE RICHVIEW USES TIMAGELIST.TAG PROPERTY.
RichView does not own any ImageList, it never destroys them. It just holds references to them.
If you want to load pictures and/or controls from RVF you need to register them with RegisterClasses procedure (you need not to register TBitmap, TMetafile, TIcon and TJpegImage - they are already registered by RichView)
You can save full information about pictures and inserted controls in RVF, but you can also use advanced feature: you can save pictures/controls yourself and include in RVF only some "identifiers" that can be used to create pictures/controls when needed (on loading). Two values can be uses as these "identifiers": RichView items tags and names.
These options do not affect loading from RVF. RichView autodetects these modes (binary/text, indices/names of styles).
const Tag: TRVTag; var ctrl: TControl);
case StrToInt(Tag) of
ctrl := TButton.Create(nil);
TButton(ctrl).Caption := Name;
ctrl := TEdit.Create(nil);
TEdit(ctrl).Text := Name;
As you can see, TRichView passes two parameters that can help you to identify your control:
▪Tag: TRVTag – TRichView item tag (do not confuse with tag properties of TComponent descendants);
▪Name: TRVUnicodeString – string that can be associated with any control or picture in RichView.
// this example assumes that images may be only bitmaps
procedure MyRichViewRVFPictureNeeded(Sender: TCustomRichView;
Index1, Index2: Integer; var gr: TGraphic);
gr := TBitmap.Create;
if (Index1>=0) and (Index2>=0) then
else if Item is TRVTableItemInfo then
else if Item is TRVGraphicItemInfo then
Pictures may be stored directly in RVF. RVF contains names of graphic classes used for these images. If you want to use the same graphic classes for loaded pictures, you need to register these classes using RegisterClasses procedure. TRichView itself registers TBitmap, TMetafile, TIcon, TJPEGImage, TWicImage (for Delphi 2010+), TPngImage (for Delphi 2009+). If you include RVGifAnimate2007 unit in your project, TGifImage will be registered as well (for Delphi 2007+). All other graphic classes must be registered explicitly. If the graphic class specified in RVF is not available when reading, TRichView will try to detect an appropriate class by the graphic content.
If you include rvfoIgnoreGraphicClasses in RichView.RVFOptions, TRichView ignores names of graphic classes stored in RVF and always tries to find a proper graphic class by graphic content.
RichView.RVFOptions define options for RVF saving and loading.
After loading you can check RichView.RVFWarnings property. Depending on RichView.RVFOptions some flags in RichView.RVFWarnings can be errors or warning:
When loading RVF, the control works according to rvfoCanChangeUnits option. If it is excluded from RVFOptions, lengths from RVF are converted to Style.Units. If it is included, and RVF contains either text or paragraph styles, existing styles are converted to units read from RVF (using Style.ConvertToDifferentUnits method), so lengths from RVF are read without conversion.
If a conversion of units is performed while reading RVF, rvfwConvUnits is included in RVFWarnings.
▪OnItemAction (ItemAction=rviaInserting and rviaInserted);