Any hack / technique to get table dimensions in pixels?

General TRichView support forum. Please post your questions here
Post Reply
nostradumbass
Posts: 6
Joined: Tue Jun 24, 2008 2:00 am

Any hack / technique to get table dimensions in pixels?

Post 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Did you try using OnDrawBorder event to draw this rounded border?
nostradumbass
Posts: 6
Joined: Tue Jun 24, 2008 2:00 am

Post by nostradumbass »

Thank you Sergey.
Post Reply