I want to get the position/placement in pixels of a text (aWord) in a TMemo. My code is something like this:
var
Size: TSize;
Pt: Cardinal;
aWord: string;
x, y: Integer;
begin
...
Pt := Perform(EM_POSFROMCHAR, aStart-1, 0);
Windows.GetTextExtentPoint32(DC, PChar(aWord), aLen, Size);
x:= Smallint(LoWord(Pt));
y:= Smallint(HiWord(Pt));
Initially it works ok, but when I scroll down the memo, I get a range check error on the last line.
How to I get the position when I scroll down?
The official documentation says:
A returned coordinate can be negative if the character has been scrolled outside the client area of the edit control. The coordinates are truncated to integer values.
I don't know how to interpret this.