How to check if RVE contain picture?

General TRichView support forum. Please post your questions here
Post Reply
CCY

How to check if RVE contain picture?

Post by CCY »

How can I check when an RVE content has picture in it?
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

var count, itemstyle;

for count := 0 to rve.ItemCount - 1 do begin
itemstyle := rve.GetItemStyle(count);
if itemstyle = rvsTable then begin
{you have to iterate through each cells}

end else if (itemstyle = rvsPicture) or (itemstyle = rvsHotPicture) then
{there is a picture!}
end;

Hope this help.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, it's possible to do it with recursive procedure.
Another way is using (undocumented) RVData.EnumItems method. This method calls the specified procedure for each item in TRichView.

Code: Select all

// This procedure will be called for each RichView item
procedure TForm3.EnumItemsProc(RVData: TCustomRVData; ItemNo: Integer;
  var UserData1: Integer; const UserData2: String;
  var ContinueEnum: Boolean);
begin
  if (RVData.GetItemStyle(ItemNo)=rvsPicture) or
     (RVData.GetItemStyle(ItemNo)=rvsHotPicture) then begin
    UserData1 := 1;
    ContinueEnum := False;
    end
  else
    ContinueEnum := True;
end;

procedure TForm3.Button1Click(Sender: TObject);
var HasPictures: Integer;
begin
  HasPictures := 0;
  RichViewEdit1.RVData.EnumItems(EnumItemsProc, HasPictures, '');
  if HasPictures<>0 then
    Caption := 'YES'
  else
    Caption := 'NO';
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The procedure above checks only picture items.
Pictures can also appear:
- as document background
- as table background
- as table cell background
- as paragraph markers (pictures-bullets)
- "hotspots" and "bullets" (pictures from image lists)

I do not know if you need to detect them all.
Post Reply