<< Click to display table of contents >>


Occurs when loading a file or a stream containing links to image files.


  TRVImportPictureEvent =

    procedure (Sender: TCustomRichView;

    const Location: TRVUnicodeString; Width, Height: Integer;

    var Graphic: TGraphic) of object;


property OnImportPicture: TRVImportPictureEvent;

(introduced in version 1.8; changed in version 18)

This event may occur:

when loading RTF. Usually pictures are saved inside RTF file/stream. But sometimes RTF contains links to external image files (file names or URLs).

when loading HTML (using RvHtmlImporter or RvHtmlViewImporter components)

when accepting URL to an image as a result of drag&drop, and rvoDragDropPicturesFromLinks is include in EditorOptions.

If these links are local (like 'c:\images\image.bmp'), TRichView can load these files itself. But if images are on the Internet (like ''), it makes sense to process this event and to download the image.

Input parameters

Location path to the file (local or URL);

Width, Height reserved, equal to 0;

Graphic nil.

Output parameters

Graphic set it to the loaded image. If you leave it equal to nil, TRichView will attempt to load the image itself.

(TRichView can load image file only if its extension is associated with some graphic class. Delphi does it automatically for TBitmap, TIcon, TMetafile, TJpegImage. If you use third-party graphic classes, you can register them using TPicture.RegisterFileFormat class procedure).


If you use RichViewActions, they can use downloader components to download pictures automatically, when loading is initiated by the action (Open, Insert File, Paste and Paste Special actions). This downloader can also be used in OLE drag&drop, see OnBeforeOleDrop and OnAfterOleDrop events.


Example: downloading images from http location using Indy (IdHTTP1: TIdHTTP)

uses RVFuncs;


{ TMyRichView.OnImportPicture }

procedure TMyForm.MyRichViewImportPicture(Sender: TCustomRichView;

  const Location: TRVUnicodeString; Width, Height: Integer;

  var Graphic: TGraphic);

var Stream: TMemoryStream;


  if Pos('http://', AnsiLowerCase(Location))=1 then


    Stream := TMemoryStream.Create;


      IdHTTP1.Get(Location, Stream);

      Stream.Position := 0;

      Graphic := RVGraphicHandler.LoadFromStream(Stream);


      Graphic := nil;






See also methods of TRichView:



See also methods of TRichViewEdit: