Esempio n. 1
0
        internal static void DrawGlowingText(Graphics graphics, string text, Font font, Rectangle bounds, Color color, TextFormatFlags flags)
        {
            Win32BitmapInfo info = null;
            IntPtr          hdc  = graphics.GetHdc();
            IntPtr          hDC  = CreateCompatibleDC(hdc);

            info = new Win32BitmapInfo {
                biSize        = Marshal.SizeOf(info),
                biWidth       = bounds.Width,
                biHeight      = -bounds.Height,
                biPlanes      = 1,
                biBitCount    = 0x20,
                biCompression = 0
            };
            IntPtr hObject = CreateDIBSection(hdc, info, 0, 0, IntPtr.Zero, 0);

            SelectObject(hDC, hObject);
            IntPtr ptr4 = font.ToHfont();

            SelectObject(hDC, ptr4);
            VisualStyleRenderer   renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
            Win32DrawThemeOptions pOptions = new Win32DrawThemeOptions {
                dwSize    = Marshal.SizeOf(typeof(Win32DrawThemeOptions)),
                dwFlags   = 0x2801,
                crText    = ColorTranslator.ToWin32(color),
                iGlowSize = 5
            };
            Win32Rect pRect = new Win32Rect(0, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);

            DrawThemeTextEx(renderer.Handle, hDC, 0, 0, text, -1, (int)flags, ref pRect, ref pOptions);
            BitBlt(hdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, hDC, 0, 0, 0xcc0020);
            DeleteObject(ptr4);
            DeleteObject(hObject);
            DeleteDC(hDC);
            graphics.ReleaseHdc(hdc);
        }
Esempio n. 2
0
 private static extern IntPtr CreateDIBSection(IntPtr hdc, Win32BitmapInfo pbmi, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);