Page 1 of 1

[H]Get table cell pixel coordinates

Posted: Wed Sep 20, 2006 6:34 am
by Pent
Hello Sergey!

Is it possible to get pixel coordinates of the top-leftmost and bottom-rightmost corners of a table cell (in pixels)? GetItemCoords doesn't do the job for me..

Posted: Thu Sep 21, 2006 8:53 am
by Sergey Tkachenko
Cell.GetOriginEx - top left corner.
Cell.Width, Heigth.

Posted: Thu Sep 21, 2006 9:08 am
by Pent
Thanks for reply!

I've tried these too, and it didn't work for me... Here is the RTF file I was working with: http://webfile.ru/1116045

I've solved the problem by using OnDrawBorder event, it works perfectly.

Posted: Thu Sep 21, 2006 9:44 am
by Sergey Tkachenko
GetOriginEx returns coordinates relative to the top left corner of document.
Client coordinates may be different because of scrolling (and TRichView.VAlign)

OnDrawBorder's coordinates are not always client coordinates, if document is repainted partially.

Posted: Thu Sep 21, 2006 11:03 am
by Pent
OnDrawBorder's coordinates are not always client coordinates, if document is repainted partially.
I understand this, so I draw document at (0,0) on an offscreen canvas right after Init/FormatNextPage to get table cell coordinates.

The methods you have suggested won't work for some reason.. Even GetCellAt doesn't work :shock: I guess it is because of the complex structure of the tables in the file (have a look at it).

Posted: Thu Sep 21, 2006 11:27 am
by Sergey Tkachenko
This document is really looks complicated. But TRichView converts all RTF tables to HTML-like tables (m x n, the same number of columns in each row, some cells may be merged). So the structure of complex and simple tables are the same.
GetCellAt requires coordinates relative to the top left corner of the table. If this method does not work correctly, mouse selection would not work too, because this method is used to find cell below the mouse pointer.

Posted: Thu Sep 21, 2006 11:45 am
by Pent
Just checked - mouse selection works Ok for TRichView.. Maybe the problem was that TRVReportHelper doesn't allow this, only TRichView(Edit) (I use TRVReportHelper)?

Anyway, thanks for support.

Posted: Fri Sep 22, 2006 12:52 pm
by Sergey Tkachenko
Yes, tables in TRVReportHelper/TRVPrint are formatted differently, you cannot use these methods in them