Page 1 of 1

InsertTable with image

Posted: Sun Apr 23, 2006 10:11 pm
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

Posted: Mon Apr 24, 2006 2:57 pm
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.

Posted: Mon Apr 24, 2006 7:18 pm
by creationgo
Thank you very much
Regards