Insert a bitmap in a table cell
Posted: Sat Sep 09, 2023 10:37 am
Hello sergey
When I insert a bitmap in a table cell. I try to free the bitmap when done, but An exception in arised Why???
Please Help!!!
procedure TFScienceStudio.InsertBitmap1Click(Sender: TObject);
var Table:TrvTableItemInfo;
BitMap:TBitmap;
Row,Col:Integer;
begin
Table:=GetTable(Rich.RichViewEdit.RVData,'');
Bitmap:=TBitmap.Create;
Row:=0;
Col:=0;
Bitmap.Canvas.Font.Size:=20;
Bitmap.Width:=Bitmap.Canvas.TextWidth('Question');
Bitmap.Height:=Bitmap.Canvas.TextHeight('Question');
Bitmap.Canvas.Font.color:=Clred;
Bitmap.Canvas.TextOut(0,0,'Hello');
Table.EditCell(Row, Col);
// moving the caret to the end of this cell
with TCustomRVFormattedData(Table.Cells[Row, Col].GetRVData) do
SetSelectionBounds(ItemCount-1, GetOffsAfterItem(ItemCount-1), ItemCount-1, GetOffsAfterItem(ItemCount-1));
Rich.RichViewEdit.InsertPicture('',Bitmap, rvvaAbsMiddle);
Rich.RichViewEdit.Change;
Rich.RichViewEdit.Format;
Bitmap.free;
end;
When I insert a bitmap in a table cell. I try to free the bitmap when done, but An exception in arised Why???
Please Help!!!
procedure TFScienceStudio.InsertBitmap1Click(Sender: TObject);
var Table:TrvTableItemInfo;
BitMap:TBitmap;
Row,Col:Integer;
begin
Table:=GetTable(Rich.RichViewEdit.RVData,'');
Bitmap:=TBitmap.Create;
Row:=0;
Col:=0;
Bitmap.Canvas.Font.Size:=20;
Bitmap.Width:=Bitmap.Canvas.TextWidth('Question');
Bitmap.Height:=Bitmap.Canvas.TextHeight('Question');
Bitmap.Canvas.Font.color:=Clred;
Bitmap.Canvas.TextOut(0,0,'Hello');
Table.EditCell(Row, Col);
// moving the caret to the end of this cell
with TCustomRVFormattedData(Table.Cells[Row, Col].GetRVData) do
SetSelectionBounds(ItemCount-1, GetOffsAfterItem(ItemCount-1), ItemCount-1, GetOffsAfterItem(ItemCount-1));
Rich.RichViewEdit.InsertPicture('',Bitmap, rvvaAbsMiddle);
Rich.RichViewEdit.Change;
Rich.RichViewEdit.Format;
Bitmap.free;
end;