From 366cedfb91a62218202ded0b5ac1641ddd93c004 Mon Sep 17 00:00:00 2001 From: ondrej Date: Sun, 17 Jul 2016 04:07:04 +0000 Subject: [PATCH] win32: support DT_MODIFYSTRING in DrawText git-svn-id: trunk@52702 - --- lcl/interfaces/win32/win32winapi.inc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lcl/interfaces/win32/win32winapi.inc b/lcl/interfaces/win32/win32winapi.inc index eada397edb..52e7ee2b34 100644 --- a/lcl/interfaces/win32/win32winapi.inc +++ b/lcl/interfaces/win32/win32winapi.inc @@ -1111,7 +1111,17 @@ begin // the length of utf8 vs Wide/Ansi the strings differ, so recalc. W := UTF8ToUTF16(s); len := Length(W); + if (Flags and DT_MODIFYSTRING <> 0) then + SetLength(W, len+4); Result := Windows.DrawTextW(DC, PWideChar(W), len, @Rect, Flags); + if (Flags and DT_MODIFYSTRING <> 0) then + begin + s := UTF16ToUTF8(W); + if s<>'' then + Move(s[1], Str^, Length(s)+1) // the programmer has to make sure there's enough space in Str + else + Str^ := #0; + end; // Theoretically, we need to augment the returned rect by the text overhang