public DRAWTEXTPARAMS(IntNativeMethods.DRAWTEXTPARAMS original) { this.cbSize = Marshal.SizeOf(typeof(IntNativeMethods.DRAWTEXTPARAMS)); this.iLeftMargin = original.iLeftMargin; this.iRightMargin = original.iRightMargin; this.iTabLength = original.iTabLength; }
public static int DrawTextEx(HandleRef hDC, string text, ref IntNativeMethods.RECT lpRect, int nFormat, [In, Out] IntNativeMethods.DRAWTEXTPARAMS lpDTParams) { int retVal = DrawTextExW(hDC, text, text.Length, ref lpRect, nFormat, lpDTParams); DbgUtil.AssertWin32(retVal != 0, "DrawTextEx(hdc=[0x{0:X8}], text=[{1}], rect=[{2}], flags=[{3}] failed.", hDC.Handle, text, lpRect, nFormat); return(retVal); }
public static extern int DrawTextExW(HandleRef hDC, string lpszString, int nCount, ref IntNativeMethods.RECT lpRect, int nFormat, [In, Out] IntNativeMethods.DRAWTEXTPARAMS lpDTParams);
public static int DrawTextEx(HandleRef hDC, string text, ref IntNativeMethods.RECT lpRect, int nFormat, [In, Out] IntNativeMethods.DRAWTEXTPARAMS lpDTParams) { int retVal; if (Marshal.SystemDefaultCharSize == 1) { // CapRectangleForWin9x(ref lpRect); // we have to do this because if we pass too big of a value (<= 2^31) to win9x // it fails and returns negative values as the rect in which it painted the text lpRect.top = Math.Min(Int16.MaxValue, lpRect.top); lpRect.left = Math.Min(Int16.MaxValue, lpRect.left); lpRect.right = Math.Min(Int16.MaxValue, lpRect.right); lpRect.bottom = Math.Min(Int16.MaxValue, lpRect.bottom); // Convert Unicode string to ANSI. int byteCount = IntUnsafeNativeMethods.WideCharToMultiByte(IntNativeMethods.CP_ACP, 0, text, text.Length, null, 0, IntPtr.Zero, IntPtr.Zero); byte[] textBytes = new byte[byteCount]; IntUnsafeNativeMethods.WideCharToMultiByte(IntNativeMethods.CP_ACP, 0, text, text.Length, textBytes, textBytes.Length, IntPtr.Zero, IntPtr.Zero); // Security: Windows 95/98/Me: This value may not exceed 8192. byteCount = Math.Min(byteCount, IntNativeMethods.MaxTextLengthInWin9x); retVal = DrawTextExA(hDC, textBytes, byteCount, ref lpRect, nFormat, lpDTParams); } else { retVal = DrawTextExW(hDC, text, text.Length, ref lpRect, nFormat, lpDTParams); } DbgUtil.AssertWin32(retVal != 0, "DrawTextEx(hdc=[0x{0:X8}], text=[{1}], rect=[{2}], flags=[{3}] failed.", hDC.Handle, text, lpRect, nFormat); return(retVal); }
public static int DrawTextEx(HandleRef hDC, string text, ref IntNativeMethods.RECT lpRect, int nFormat, [In, Out] IntNativeMethods.DRAWTEXTPARAMS lpDTParams) { if (Marshal.SystemDefaultCharSize == 1) { lpRect.top = Math.Min(0x7fff, lpRect.top); lpRect.left = Math.Min(0x7fff, lpRect.left); lpRect.right = Math.Min(0x7fff, lpRect.right); lpRect.bottom = Math.Min(0x7fff, lpRect.bottom); int num2 = WideCharToMultiByte(0, 0, text, text.Length, null, 0, IntPtr.Zero, IntPtr.Zero); byte[] pOutBytes = new byte[num2]; WideCharToMultiByte(0, 0, text, text.Length, pOutBytes, pOutBytes.Length, IntPtr.Zero, IntPtr.Zero); num2 = Math.Min(num2, 0x2000); return(DrawTextExA(hDC, pOutBytes, num2, ref lpRect, nFormat, lpDTParams)); } return(DrawTextExW(hDC, text, text.Length, ref lpRect, nFormat, lpDTParams)); }