rve.GetItemCoords identifies 1st line of multline Paragraph

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

rve.GetItemCoords identifies 1st line of multline Paragraph

Post by j&b »

Hello Sergey,

recently you helped me, to jump to a y- position in the memo ("procedure TForm1.Go2memoYpos").
The procedure works correctly.

In the meanwhile, I noticed that the identification of the y-position in a memo with "rve.GetItemCoords" is not correct.
"rve.GetItemCoords" identifies always the 1st line of a multi-paragraph. But I need the correct y-Position.
"OnMouseMoveUp" also doesn't work correct for what I want. If someone needs the y-position in rve, this procedure refers always to the y-position in memo-window (as soon as I scroll, y-Pos is wrong).

Is there a counterpart to "Go2memoYpos"?

Jürgen



procedure TForm1.Go2memoYpos; //---> OK <-----
var RVData:TCustomRVFormattedData;
ItemNo, OffsetInItem: Integer;
begin
rve.GetItemAt(0, rveYpos, RVData, ItemNo, OffsetInItem, False);
RVData := TCustomRVFormattedData(RVData.Edit);
RVData.SetSelectionBounds(ItemNo, OffsetInItem, ItemNo, OffsetInItem);
end;
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

uses CRVFData, DLines;

Code: Select all

procedure GetCaretY(rve: TCustomRichViewEdit): Integer;
var DItemNo, DItemOffs, X, Y: Integer;
begin
  rve := rve.TopLevelEditor;
  rve.RVData.Item2DrawItem(rve.CurItemNo, rve.OffsetInCurItem, DItemNo, DItemOffs);
  rve.RVData.GetOriginEx(X, Y);
  Result := rve.RVData.DrawItems[DItemNo].Top+Y;
end;
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

"rve.GetItemCoords identifies 1st line of multline Para

Post by j&b »

Thanks, Sergey. It seems all oK.


I have deleted my changes because of Sergey answere (look next note).
Last edited by j&b on Sat May 17, 2008 5:17 pm, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Units DLines and CRVFData must still be added in "uses" of the unit where these functions are defined, otherwise the compiler will report error on lines with .Item2DrawItem and .Top.
There is nothing wrong with using these units, they are already used by trichview code.

Without the line rve := rve.TopLevelEditor, your code will not work when the caret is inside table cell (the table's Y coordinate will be returned instead of the caret's Y). Of course, rve must be local to this function (parameter), so assignment to it will not change a global rve.
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

Thanks.

I will confine my changes and delete them in the above note.
Post Reply