DisplayPosToXY Method


Applies to

THtmlViewer component

Declaration

function DisplayPosToXY(DisplayPos: integer; var X, Y: integer): boolean;

Description

Given a character position in the display, DisplayPosToXY finds the X and Y location of the character on the display. Dimensions are in pixels relative to the upper left corner of the display.

DisplayPosToXY returns False if the requested position does not exist.

Example:

The following code will check to see if the selected position is within the currently displayed area If not it will position the display to insure that it is

if Viewer.DisplayPosToXY(Viewer.SelStart, X, Y) then

begin

VPos := Viewer.VScrollBarPosition;

if (Y < VPos) or (Y > VPos +Viewer.ClientHeight-20) then

Viewer.VScrollBarPosition := (Y - Viewer.ClientHeight div 2);

end;

See Also:

SelStart Property

FindSourcePos Method

FindDisplayPos Method