InsertTable with image

General TRichView support forum. Please post your questions here
Post Reply
creationgo
Posts: 7
Joined: Fri Jan 13, 2006 8:01 am

InsertTable with image

Post by creationgo »

Hi
I always have an error when I close my application after do it:

aTable:= TRVTableItemInfo.CreateEx(1,1, Rve.RVData);
if Image1.Picture.graphic<> nil then begin
aTable.Cells[0,0].Clear;
aTable.Cells[0,0].AddPictureEx(aName,Image1.Picture.Graphic,-1,rvvaBaseline);
rve.InsertItem('',aTable);

Regards
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You need to create a copy of graphic, because TRichView frees inserted images.

Code: Select all

var gr: TGraphic;

aTable:= TRVTableItemInfo.CreateEx(1,1, Rve.RVData); 
if Image1.Picture.graphic<> nil then begin 
  aTable.Cells[0,0].Clear; 
  // RV_CreateGraphics is defined in RVFuncs.pas
  gr := RV_CreateGraphics(TGraphicClass(Image1.Picture.Graphic.ClassType));
  gr.Assign(Image1.Picture.Graphic);
  aTable.Cells[0,0].AddPictureEx(aName,gr,0,rvvaBaseline); 
end;
rve.InsertItem('',aTable); 
PS: documents (and cells) must not start from item continuing paragraph (ParaNo=-1); this error is fixed automatically, but for any case, I changed -1 to 0.
creationgo
Posts: 7
Joined: Fri Jan 13, 2006 8:01 am

Post by creationgo »

Thank you very much
Regards
Post Reply