rvico TRichView Reference | TRichView

TCustomRichView.SetPictureInfo

Top  Previous  Next

Changes main properties of the item of picture or hot-picture type.

function SetPictureInfo(ItemNo: Integer; const  AName: TRVAnsiString;

  Agr: TGraphic; AVAlign: TRVVAlignconst ATag: TRVTag): Boolean;

Parameters:

ItemNo – index of the item. The item must be of picture or hot-picture type (rvsPicture or rvsHotPicture), otherwise the method raises ERichViewError exception. Items are indexed from 0 to ItemCount-1, GetItemStyle returns type of item. Items of subdocuments (table cells) are not included in the items range of the main document; for items in cells, use Cell.GetRVData.SetPictureInfo.

AName – name of the item, any string without line break (CR, LF) characters. It can also be set using SetItemText method.

Agr – graphic object. If this item does not use a shared image (by default), Agr must be an unique graphic object (you cannot assign the same graphic object to two or more items) or the value returned by GetPictureInfo for this item (the image is shared if rvepShared extra item property is nonzero). If this item does not use a shared image, and Agr is not equal to the value returned by GetPictureInfo for this item, the previously used graphic object is freed.

AVAlign – vertical alignment of the picture.

ATag tag of the item.You can use value returned by GetPictureInfo or GetItemTag for this item. The tag can also be set by SetItemTag method.

 

Return value: is reformatting needed? (are the size and the vertical align of the new picture not equal to the size and the vertical align of the old one?)

 

Method type: viewerstyle viewer-style.

Additional item properties are assigned by the methods SetItemExtraIntProperty and SetItemExtraStrProperty (including stretching, transparency for bitmaps, link to file name, alternative text for saving to HTML).

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

 

Example 1

RichView1.SetPictureInfo(ItemNo, 'my image', Bitmap2, rvvaBaseline, 'image tag');

Example 2 (incorrect!)

bmp := TBitmap.Create;

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

RichView1.SetPictureInfo(ItemNo1, '', bmp, rvvaBaseline, '');

RichView1.SetPictureInfo(ItemNo2, '', bmp, rvvaBaseline, ''); // incorrect! you cannot assign

  // the same graphic object to different items

Example 2 (the same, but correct)

bmp1 := TBitmap.Create;

bmp1.LoadFromFile('c:\image.bmp');

RichView1.SetPictureInfo(ItemNo1, '', bmp1, rvvaBaseline, '');

bmp2 := TBitmap.Create;

bmp2.Assign(bmp1);

RichView1.SetPictureInfo(ItemNo2, '', bmp2, rvvaBaseline, '');

Example 2 (the same, using shared images)

bmp := TBitmap.Create;

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

RichView1.SetPictureInfo(ItemNo1, '', bmp, rvvaBaseline, '');

RichView1.SetItemExtraIntProperty(ItemNo1, rvepShared, 1);

RichView1.SetPictureInfo(ItemNo2, '', bmp, rvvaBaseline, '');

RichView1.SetItemExtraIntProperty(ItemNo2, rvepShared, 1);

// you must free bmp yourself when RichView1 is cleared

 

See also methods:

GetPictureInfo;

GetItemStyle;

Format;

SetItemExtraIntProperty;

SetItemExtraStrProperty.

See also properties:

ItemCount.

See also methods of RichViewEdit:

SetPictureInfoEd;

SetCurrentPictureInfo.

See also:

Modifying RichView items;

Item types;

Tags.


TRichView © trichview.com