Drag&Drop in TRichView

<< Click to display table of contents >>

Drag&Drop in TRichView

You can drag data from TRichView or TRichViewEdit. You can drop data to TRichViewEdit.

Drag&drop is possible not only inside the same editor, but between different controls and even between different applications.

For example, you can drop files from Windows Explorer, hyperlinks, text and images from Internet Explorer or Word.

Dragging from TRichView or TRichViewEdit [VCL, LCL]

TRichView provides data in the following formats:

RichView Format ('RichView Format')

RTF ('Rich Text Format')

ANSI text (CF_TEXT)

Unicode text (CF_UNICODETEXT)

bitmap (CF_BITMAP), if TBitmap picture is selected

metafile (CF_ENHMETAFILE), if TMetafile picture is selected.

You can disallow dragging from the given TRichView by including rvoDisallowDrag in the Options property.

TRichView cannot initialize dragging of inserted controls. If you want to drag them, use BeginOleDrag method.

Dragging to TRichViewEdit [VCL, LCL]

AcceptDragDropFormat lists formats that can be accepted.

By default all formats are accepted except for URL (because it requires processing in OnReadHyperlink)

Dropped object can contain data in multiple formats. The priority is: RVF, then RTF, then files, then URL, then Unicode text, then ANSI text, then bitmap, then metafile.

If rvoDragDropPicturesFromLinks is included in EditorOptions, and the dropped URL is a link to a picture, the editor attempts to insert it as a picture, not as a link.

If rvoAssignImageFileNames in Options, file name is is stored in rvespImageFileName extra string property for pictures; you can modify this file name in OnAssignImageFileName event.

The following events may occur:

OnReadHyperlink;

OnDropFile;

OnDropFiles.

You can customize drag&drop process using the following low level events:

OnOleDragEnter;

OnOleDragOver;

OnOleDragLeave;

OnOleDrop,

OnBeforeOleDrop and OnAferOleDrop

Drag&Drop in FireMonkey

When dragging between TRichView/TRichViewEdit controls within the same application, data are transferred using the most appropriate format from AcceptDragDropFormat.

When dragging from TRichView to other target, data are provided as text or as an image (if an image is selected).

When dragging from TRichViewEdit, data are accepted as files, text, or an image.

See also...

Clipboard