Coordinates of the object on the page, if it is in the table

General TRichView support forum. Please post your questions here
Post Reply
Vitalii
Posts: 69
Joined: Sat Oct 20, 2018 2:55 pm

Coordinates of the object on the page, if it is in the table

Post by Vitalii »

I have a question about the coordinates of the TCustomRVItemInfo object on the page. I need to draw a graphic primitive next to the object. Everything works fine, but if the object is in a table, the approach failed. Here is a part of a code:

Code: Select all

procedure TEditor.SRVEditPaint(Sender: TSRichViewEdit; Canvas: TCanvas; Prepaint: Boolean; PaintRect: TRect);
begin
  { .. }
  PageNo := Sender.GetPageNo( RVData, Node.ItemNo, 0 );
  BoundRect := Sender.GetItemBounds( RVData, Node.ItemNo );
  PageClientRect := Sender.GetPageClientRect(PageNo);
  X1 := BoundRect.Left   + PageClientRect.Left;
  Y1 := BoundRect.Top    + PageClientRect.Top;
  X2 := BoundRect.Right  + PageClientRect.Left;
  Y2 := BoundRect.Bottom + PageClientRect.Top;
  Canvas.Rectangle( X1, Y1, X2, Y2 );
  { .. }
end;
How can I correctly take into account that an object is in a table?
standay
Posts: 317
Joined: Fri Jun 18, 2021 3:07 pm

Re: Coordinates of the object on the page, if it is in the table

Post by standay »

I don't use the SRVE, but maybe you have to reference the TopLevelEditor? I have to do that with the regular rve to handle table stuff, e.g., rve.TopLevelEditor...

Stan
Vitalii
Posts: 69
Joined: Sat Oct 20, 2018 2:55 pm

Re: Coordinates of the object on the page, if it is in the table

Post by Vitalii »

standay wrote: Sat Jan 03, 2026 7:23 pm I don't use the SRVE, but maybe you have to reference the TopLevelEditor? I have to do that with the regular rve to handle table stuff, e.g., rve.TopLevelEditor...
Hi Stan, you're right. The key is in the correct RVData. I changed the linear text loop to a recursive table loop, and now the coordinates are calculated correctly. Thanks!
Sergey Tkachenko
Site Admin
Posts: 18011
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Coordinates of the object on the page, if it is in the table

Post by Sergey Tkachenko »

For any case, see the ScaleRichView demos in Demos\Delphi\CustomDraw\Rectangles\
This folder has demos that draw rectangles:
- around all items
- around the item below the mouse pointer
- around the item containing the caret
Post Reply