Author: jimtabor
Date: Thu Dec 22 16:39:33 2016
New Revision: 73475
URL:
http://svn.reactos.org/svn/reactos?rev=73475&view=rev
Log:
[Win32SS|RTL]
- Fix clipping for Draw Text. Inspired by Katayama Hirofumi MZ patch and
ComCtl32/RichEd20/UxThmems. See CORE-2201.
Modified:
trunk/reactos/win32ss/user/rtl/text.c
Modified: trunk/reactos/win32ss/user/rtl/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/rtl/text.c?re…
==============================================================================
--- trunk/reactos/win32ss/user/rtl/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/rtl/text.c [iso-8859-1] Thu Dec 22 16:39:33 2016
@@ -986,6 +986,9 @@
int prefix_offset;
ellipsis_data ellip;
BOOL invert_y=FALSE;
+
+ HRGN hrgn = 0;
+
#ifdef _WIN32K_
TRACE("%S, %d, %08x\n", str, count, flags);
#else
@@ -1072,7 +1075,40 @@
}
if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
-
+#ifndef _WIN32K_ ///// Fix CORE-2201.
+ if (!(flags & DT_NOCLIP) )
+ {
+ int hasClip;
+ hrgn = CreateRectRgn(0,0,0,0);
+ if (hrgn)
+ {
+ hasClip = GetClipRgn(hdc, hrgn);
+ // If the region to be retrieved is NULL, the return value is 0.
+ if (hasClip != 1)
+ {
+ DeleteObject(hrgn);
+ hrgn = NULL;
+ }
+ IntersectClipRect(hdc, rect->left, rect->top, rect->right,
rect->bottom);
+ }
+ }
+#else
+ if (!(flags & DT_NOCLIP) )
+ {
+ int hasClip;
+ hrgn = NtGdiCreateRectRgn(0,0,0,0);
+ if (hrgn)
+ {
+ hasClip = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN);
+ if (hasClip != 1)
+ {
+ GreDeleteObject(hrgn);
+ hrgn = NULL;
+ }
+ NtGdiIntersectClipRect(hdc, rect->left, rect->top, rect->right,
rect->bottom);
+ }
+ }
+#endif /////
if (flags & DT_MODIFYSTRING)
{
size_retstr = (count + 4) * sizeof (WCHAR);
@@ -1226,6 +1262,26 @@
}
while (strPtr && !last_line);
+#ifndef _WIN32K_
+ if (!(flags & DT_NOCLIP) )
+ {
+ SelectClipRgn(hdc, hrgn);
+ if (hrgn)
+ {
+ DeleteObject(hrgn);
+ }
+ }
+#else
+ if (!(flags & DT_NOCLIP) )
+ {
+ NtGdiExtSelectClipRgn(hdc, hrgn, RGN_COPY);
+ if (hrgn)
+ {
+ GreDeleteObject(hrgn);
+ }
+ }
+#endif
+
if (flags & DT_CALCRECT)
{
rect->right = rect->left + max_width;