[H]Get table cell pixel coordinates

General TRichView support forum. Please post your questions here
Post Reply
Pent
Posts: 8
Joined: Wed Sep 20, 2006 6:30 am

[H]Get table cell pixel coordinates

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

Post by Sergey Tkachenko »

Cell.GetOriginEx - top left corner.
Cell.Width, Heigth.
Pent
Posts: 8
Joined: Wed Sep 20, 2006 6:30 am

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

Post 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.
Pent
Posts: 8
Joined: Wed Sep 20, 2006 6:30 am

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

Post 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.
Pent
Posts: 8
Joined: Wed Sep 20, 2006 6:30 am

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

Post by Sergey Tkachenko »

Yes, tables in TRVReportHelper/TRVPrint are formatted differently, you cannot use these methods in them
Post Reply