user32: Don't scale draw text margin params by character width units.

Values passed in DRAWTEXTPARAMS are already in average character width
units.
This commit is contained in:
Ulrich Czekalla 2009-02-02 13:47:00 -05:00 committed by Alexandre Julliard
parent a1f05593f3
commit 209820c428
2 changed files with 19 additions and 2 deletions

View File

@ -316,6 +316,23 @@ static void test_DrawTextCalcRect(void)
ok(textheight==0,"Got textheight from DrawTextExA\n");
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
/* Margin calculations */
dtp.cbSize = sizeof(dtp);
dtp.iLeftMargin = 0;
dtp.iRightMargin = 0;
SetRect( &rect, 0, 0, 0, 0);
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
textlen = rect.right; /* Width without margin */
dtp.iLeftMargin = 8;
SetRect( &rect, 0, 0, 0, 0);
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
ok(rect.right==dtp.iLeftMargin+textlen ,"Incorrect left margin calculated rc(%d,%d)\n", rect.left, rect.right);
dtp.iLeftMargin = 0;
dtp.iRightMargin = 8;
SetRect( &rect, 0, 0, 0, 0);
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
ok(rect.right==dtp.iRightMargin+textlen ,"Incorrect right margin calculated rc(%d,%d)\n", rect.left, rect.right);
/* Wide char versions */
SetRect( &rect, 10,10, 100, 100);
SetLastError( 0);

View File

@ -900,8 +900,8 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
if (dtp)
{
lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
rmargin = dtp->iRightMargin * tm.tmAveCharWidth;
lmargin = dtp->iLeftMargin;
rmargin = dtp->iRightMargin;
if (!(flags & (DT_CENTER | DT_RIGHT)))
x += lmargin;
dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */