Commit 5dfacee5 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Return 1 in DrawTextEx() when calculated offset is 0.

The return value 0 in DrawTextEx() indicates failure. Should the offset from the bottom of the drawn text to top of the rectangle happens to be 0, return 1 instead. So that it doesn't indicate failure incidentally. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5da1f826
......@@ -277,6 +277,21 @@ static void test_DrawTextCalcRect(void)
ok(textheight==0,"Got textheight from DrawTextA\n");
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
/* When offset to top is zero, return 1 */
SetRectEmpty(&rect);
textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
SetRect(&rect, 0, 100, 0, 100);
textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
SetRectEmpty(&rect);
textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_TOP, NULL);
/* Set top to text height and bottom zero, so bottom of drawn text to top is zero when DT_VCENTER is used */
SetRect(&rect, 0, textheight, 0, 0);
textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_VCENTER, NULL);
ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
/* invalid dtp size test */
dtp.cbSize = -1; /* Invalid */
......
......@@ -1064,6 +1064,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
if (retstr) memcpy(str, retstr, size_retstr);
ret = y - rect->top;
if (ret == 0) ret = 1;
done:
heap_free(retstr);
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment