rvico TRichView Reference | TRichView

TCustomRichView.AddPictureEx, AddPictureExTag

TCustomRichView.AddPicture (deprecated)

Top  Previous  Next

These methods add picture (gr) with the specified Name and vertical alignment (VAlign) to the end of document

procedure AddPictureExTag(const Name: TRVAnsiString; gr: TGraphic;

  ParaNo: Integer; VAlign: TRVVAlignconst Tag: TRVTag);

procedure AddPictureEx(const Name: TRVAnsiString; gr: TGraphic;

  ParaNo: Integer; VAlign: TRVVAlign);

procedure AddPicture(gr: TGraphic); deprecated;

AddPictureEx provides a subset of functionality of AddPictureExTag:

AddPictureEx(...) is equivalent to AddPictureExTag(..., '').

The same as AddHotPicture and AddHotPictureTag, but this picture will not be a hypertext link.

AddPicture is deprecated and maintained for backward compatibility (with TRichView versions prior to 1.0):

AddPicture(gr) is equivalent to AddPictureEx('', gr, 1, rvvaBaseline).

 

Parameters:

Name – name of this picture item, any string. Name must not contain CR and LF characters. RichView does not use Names itself, they are for your own use. This is an ANSI string, regardless of Unicode mode of text styles.

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.

If ParaNo=-1, the methods add the item to the end of the last paragraph. If ParaNo>=0, this item starts a new paragraph with the ParaNo-th style. (ParaNo is an index in the ParaStyles collection of the linked RVStyle component). It defines attributes for the new paragraph.

Tagtag of this picture item.

 

Alternatives:

If you want to add a TGraphic picture-hyperlink, add a hot picture instead.

If you want to add a hyperlink-picture from image list, add a hotspot instead.

If you want to add a simple (not a hyperlink) picture from image list, add a bullet instead.

 

Methods type: viewerstyle viewer-style.

unicode Unicode note: names of non-text items are ANSI strings.

Example 1:

procedure AddBitmapFromFile(rv: TCustomRichView; 

  const FileName: String; ParaNo: Integer);

var bmp: TBitmap;

begin

  bmp := TBitmap.Create;

  bmp.LoadFromFile(FileName);

  rv.AddPictureEx('', bmp, ParaNo, rvvaBaseline);

end;

...

// creating document with 2 pictures

// in the same paragraph

rv.Clear;

AddBitmapFromFile(rv, 'd:\pic1.bmp'0);

AddBitmapFromFile(rv, 'd:\pic2.bmp', -1);

rv.Format;

Example 2: adding shared images

procedure AddBitmapFromFile(rv: TCustomRichView; 

  const FileName: String; ParaNo: Integer);

 

bmp := TBitmap.Create;

bmp.LoadFromFile('c:\pic.bmp');

rv.AddPictureEx('', bmp, 0, rvvaBaseline);

rv.SetItemExtraIntProperty(rv.ItemCount-1, rvepShared, 1);

rv.AddPictureEx('', bmp, -1, rvvaBaseline);

rv.SetItemExtraIntProperty(rv.ItemCount-1, rvepShared, 1);

rv.Format;

// you must free bmp yourself when rv is cleared.

See also methods:

Format;

FormatTail;

SetAddParagraphMode.

See also methods of TRichViewEdit:

InsertPicture.

See also properties of TRVStyle:

ParaStyles.

See also:

Item types;

Other methods for appending items;

"Tags".


TRichView © trichview.com