Lazarus

Programming => General => Topic started by: big_M on July 05, 2022, 01:39:36 pm

Title: DrawText "cursor" position
Post by: big_M on July 05, 2022, 01:39:36 pm
So, I'm currently using DrawText to write text on a canvas with a fixed width, but I need to paint something in between, or behind the text. Is there any way to get the coordinates of the end of the text? I thought I could maybe use canvas.penpos, but that stays at (0,0) after I used DrawText. Maybe canvas.textout could work, but then I would have to manage the line breaks myself I think, so if I could get the coordinates using DrawText would be great. Any idea?
Title: Re: DrawText "cursor" position
Post by: Handoko on July 05, 2022, 01:52:31 pm
Maybe TextExtend can help, see this demo:

https://forum.lazarus.freepascal.org/index.php/topic,46775.msg333936.html#msg333936
Title: Re: DrawText "cursor" position
Post by: big_M on July 05, 2022, 02:17:47 pm
Interesting, that might help. Thanks!
Title: Re: DrawText "cursor" position
Post by: AlexTP on July 05, 2022, 05:52:58 pm
You can use TCanvas.TextWidth(S).
TinyPortal © 2005-2018