[PATCH 2/2] user32: Respect margins more in DrawTextExW().

Zhiyi Zhang zzhang at codeweavers.com
Mon Jun 4 06:58:07 CDT 2018


Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/user32/text.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index 286c4f52d0..118dbeb559 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -943,6 +943,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
     {
         lmargin = dtp->iLeftMargin;
         rmargin = dtp->iRightMargin;
+        width -= lmargin + rmargin;
         if (!(flags & (DT_CENTER | DT_RIGHT)))
             x += lmargin;
         dtp->uiLengthDrawn = 0;     /* This param RECEIVES number of chars processed */
@@ -978,9 +979,10 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
             last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
 	strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags, &size, last_line, retstr, tabwidth, &prefix_offset, &ellip);
 
-	if (flags & DT_CENTER) x = (rect->left + rect->right -
-				    size.cx) / 2;
-	else if (flags & DT_RIGHT) x = rect->right - size.cx;
+        if (flags & DT_CENTER)
+            x = (rect->left + lmargin + rect->right - rmargin - size.cx) / 2;
+        else if (flags & DT_RIGHT)
+            x = rect->right - size.cx - rmargin;
 
 	if (flags & DT_SINGLELINE)
 	{
-- 
2.17.0




More information about the wine-devel mailing list