Page 1 of 1

Any hack / technique to get table dimensions in pixels?

Posted: Wed Jul 30, 2008 10:28 pm
by nostradumbass
My requirement is: I need to draw a shape (rounded rectangle) on an image and set this image as the background image of the table. The image dimensions should be equal to to the height and width of the table, so that it gives an appearance of the contents of the table should be 'surrounded' by a rounded rectangle.

I have tried so many combinations, ie adding cell heights, cell bestheights, table heights, table bestheight - no luck so far.

Is there any way to get the table width and height?

my code :

Code: Select all

tbl := TRVTableItemInfo.CreateEx(2, 2, rvFtr1.RVData);

//background image for a cell
p := TJpegImage.Create;
p.LoadFromFile('c:\temp\a.jpg');
tbl.Cells[0,0].BackgroundImage := p;
tbl.Cells[0,0].BackgroundStyle := rvbsStretched ;
tbl.Cells[0,0].BestHeight:=  100;
tbl.Cells[0,0].BestWidth :=  100;

tbl.Cells[0,1].LoadRTFFromStream(footerInfo.Content);

rVFtr1.AddItem('footer table', tbl);

i := TBitmap.Create;

rvFtr1.Format;

[color=red]// I need to set the image dimensions here !!
// But how to get the table dimensions ???
i.Height:= tbl.Cells[0,0].Height + tbl.Cells[1,0].Height;
i.Width:=  tbl.Cells[0,0].Width + tbl.Cells[0,1].Width ;[/color]

i.Canvas.Pen.Color := clBlack;
i.Canvas.RoundRect(2, 2, i.Width - 2, i.Height- 2 , 20, 20);

tbl.BackgroundImage := i;
tbl.BackgroundStyle:=rvbsCentered ;

Thanks in advance,
ND

Posted: Fri Aug 01, 2008 7:16 pm
by Sergey Tkachenko
Did you try using OnDrawBorder event to draw this rounded border?

Posted: Fri Aug 01, 2008 8:34 pm
by nostradumbass
Thank you Sergey.