TSRichViewEdit.ConvertSRVtoRV

<< Click to display table of contents >>

TSRichViewEdit.ConvertSRVtoRV

Converts client coordinates in this TSRichViewEdit component to client coordinates of ActiveEditor.

function ConvertSRVtoRV(p: TPoint; var bInTextArea, bInLeft, bInPageArea: Boolean): TPoint;

Input parameters:

p – coordinates relative to the top left corner of TSRichViewEdit's window.

Output parameters:

bInTextAreaTrue if p is inside of some page's content area.

bInLeftTrue if p is to the left of some page (in the "line selection" area).

InPageAreaTrue if p is inside of some page's area (above content or above margins).

Return value:

coordinates relative to the top left corner of ActiveEditor.

See also:

ConvertRVToSRV

 

Example:

This code assigns text of the item at the position of the mouse pointer to Label1.Caption

// OnMouseMove event

procedure TForm3.SRichViewEdit1MouseMove(Sender: TObject;

  Shift: TShiftState; X, Y: Integer);

var pt: TPoint;

  RVData: TCustomRVFormattedData;

  InPageArea, InLeftArea, InTextArea: Boolean;

  ItemNo, Offs: Integer;

begin

  pt := SRichViewEdit1.ConvertSRVtoRV(Point(X, Y), InTextArea,

    InLeftArea, InPageArea);

  if InTextArea then begin

    pt := SRichViewEdit1.ActiveEditor.ClientToDocument(pt);

    SRichViewEdit1.ActiveEditor.GetItemAt(pt.X, pt.Y,

      RVData, ItemNo, Offs, True);

    if ItemNo>=0 then

      Label1.Caption := RVData.GetItemText(ItemNo)

    else // in page, but not in item

      Label1.Caption := '';

    end

  else // not in page

    Label1.Caption := '';

end;