private void ClearRopString(_TextInfo textInfo, bool isRecovery) { IntPtr[] cHDCs = textInfo.hDCs; Rectangle cRect = textInfo.Rectangle; IntPtr hMemDC = cHDCs[0]; IntPtr hBitmap = cHDCs[1]; IntPtr cOldObject = cHDCs[2]; if (isRecovery) { BitBlt(__cHDC, cRect.X, cRect.Y, cRect.Width, cRect.Height, hMemDC, 0, 0, TernaryRasterOperations.SRCCOPY); } SelectObject(hMemDC, cOldObject); DeleteObject(hBitmap); DeleteDC(hMemDC); }
internal _TextInfo DrawRopString(string text, Color color, int x, int y) { Size cSize = this.MeasureString(text); IntPtr hMemDC = CreateCompatibleDC(__cHDC); IntPtr hBitmap = CreateCompatibleBitmap(__cHDC, cSize.Width, cSize.Height); IntPtr cOldObject = SelectObject(hMemDC, hBitmap); BitBlt(hMemDC, 0, 0, cSize.Width, cSize.Height, __cHDC, x, y, TernaryRasterOperations.SRCCOPY); int iOldColor = SetTextColor(__cHDC, ColorTranslator.ToWin32(color)); TextOut(__cHDC, x, y, text, text.Length); _TextInfo cTextInfo = new _TextInfo(new IntPtr[] { hMemDC, hBitmap, cOldObject }, x, y, cSize.Width, cSize.Height); if (__bSaveRop) { __cTextInfos.Add(cTextInfo); } return(cTextInfo); }
internal _TextInfo DrawRopString(string text, Color foreColor, Color background, int x, int y, Rectangle rect) { IntPtr hMemDC = CreateCompatibleDC(__cHDC); IntPtr hBitmap = CreateCompatibleBitmap(__cHDC, rect.Width, rect.Height); IntPtr cOldObject = SelectObject(hMemDC, hBitmap); BitBlt(hMemDC, 0, 0, rect.Width, rect.Height, __cHDC, rect.X, rect.Y, TernaryRasterOperations.SRCCOPY); int iOldColor = SetTextColor(__cHDC, ColorTranslator.ToWin32(foreColor)); int iOldBackColor = SetBkColor(__cHDC, ColorTranslator.ToWin32(background)); Rectangle4 cRect4 = new Rectangle4(rect); ExtTextOut(__cHDC, 0, 0, ETOOptions.ETO_OPAQUE, ref cRect4, string.Empty, 0, IntPtr.Zero); TextOut(__cHDC, rect.X + x, rect.Y + y, text, text.Length); SetBkColor(__cHDC, iOldBackColor); _TextInfo cTextInfo = new _TextInfo(new IntPtr[] { hMemDC, hBitmap, cOldObject }, rect.X, rect.Y, rect.Width, rect.Height); if (__bSaveRop) { __cTextInfos.Add(cTextInfo); } return(cTextInfo); }