<< Click to display table of contents >> TCustomRichViewEdit.InsertPicture |
Inserts picture at the position of caret.
function InsertPicture(const Name: TRVUnicodeString; gr: TRVGraphic;
VAlign: TRVVAlign; ImageWidth: TRVStyleLength = 0;
ImageHeight: TRVStyleLength = 0): Boolean;
(changed in version 18 and 21)
Parameters:
Name – name of this picture item, any string. Name must not contain CR and LF characters. TRichView does not use items names itself, they are for your own use.
gr – picture to insert. By default, this picture will be owned by TRichView control, and you must not free it. However, you can specify nonzero rvepShared extra item property, and this graphic object will be shared (you need to free it yourself after TRichView is cleared).
Rarely used images may be "deactivated", i.e. stored in a memory stream and destroyed (see RichViewMaxPictureCount). Shared images are never deactivated.
VAlign – vertical align of this picture, relative to its line, see TRVVAlign for possible values.
The image is displayed stretched to ImageWidth x ImageHeight (if they are non-zero, see rvepImageWidth and rvepImageHeight in IDH_Type_TRVExtraItemProperty).
Method type: editing-style method for insertion.
If you want this picture to be a hypertext link, use InsertHotPicture instead.
Return value
True if the insertion was successful (it can fail due to protection, or when inserting in table having multicell selection). If insertion failed, TRichViewEdit destroys gr.
Example (inserting icon from file)
var ico: TIcon;
...
ico := TIcon.Create;
ico.LoadFromFile('My Icon.ico');
MyRichViewEdit.InsertPicture('',ico, rvvaBaseline);
Example 2 (inserting picture of any supported format):
var gr: TRVGraphic;
...
if OpenPictureDialog1.Execute then
gr := RVGraphicHandler.LoadFromFile(OpenPictureDialog1.FileName);
if gr<>nil then
MyRichViewEdit.InsertPicture('', gr, rvvaBaseline)
else
// process a picture loading error here
end;
See also methods of TCustomRichView:
See also: