[Lazarus] GetTextExtent on Windows

Marc Weustink marc at dommelstein.nl
Sun Sep 13 22:09:46 CEST 2015



On September 12, 2015 2:12:32 PM GMT+02:00, "Jürgen Hestermann" <juergen.hestermann at gmx.de> wrote:
>I use "LCLIntf.DrawText" for drawing text on the screen and
>"Canvas.TextWidth"
>to determine its width to increment a TRect for the next text output.
>But these functions cause some trouble with drawing (UTF-8-) text on
>Windows.
>In general it works okay but sometimes peculiar clipping or other pixel
>differences occur.
>Are the functions above the correct ones to draw and measure text?
>
>After looking a bit at the code I saw that in the file
>"intfbasewinapi.inc" almost
>everywhere the Windows API function "GetTextExtentPoint" is used to
>determine text metrics.
>But
>https://msdn.microsoft.com/en-us/library/windows/desktop/dd144937%28v=vs.85%29.aspx
>says:
>"This function is provided only for compatibility with 16-bit versions
>of Windows.
>Applications should call the *GetTextExtentPoint32*
><https://msdn.microsoft.com/en-us/library/windows/desktop/dd144938%28v=vs.85%29.aspx>
>function, which provides more accurate results."
>
>I think many of my problems come from using this deprecated API
>function.
>Are there any plans to change this?

If you had a look at the win32 implementation of GetTextExtentPoint then you would have seen that GetTextExtentPoint32 is used internally. 

Marc






More information about the Lazarus mailing list