Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            using (GDIOffscreenBitmap hBitmapOffscreen = new GDIOffscreenBitmap(e.Graphics, ClientSize.Width, ClientSize.Height))
            {
                using (Brush backBrush = new SolidBrush(BackColor))
                {
                    hBitmapOffscreen.Graphics.FillRectangle(backBrush, ClientRectangle);
                }
                MyTextRenderer.DrawText(hBitmapOffscreen.Graphics, text, Font, new Point(), ForeColor);
                using (GDIRegion gdiRgnClip = new GDIRegion(e.Graphics.Clip.GetHrgn(e.Graphics)))
                {
                    using (GraphicsHDC hDC = new GraphicsHDC(e.Graphics))
                    {
                        // Graphics/GDI+ doesn't pass clip region through so we have to reset it explicitly
                        GDI.SelectClipRgn(hDC, gdiRgnClip);

                        bool f = GDI.BitBlt(
                            hDC,
                            0,
                            0,
                            hBitmapOffscreen.Width,
                            hBitmapOffscreen.Height,
                            hBitmapOffscreen.HDC,
                            0,
                            0,
                            GDI.SRCCOPY);
                    }
                }
            }
            base.OnPaint(e);
        }
Exemplo n.º 2
0
 public virtual void SetWindowRegion(GDIRegion aRegion)
 {
     RegionCombineType retValue = (RegionCombineType)User32.SetWindowRgn(Handle, aRegion.DangerousGetHandle(), true);
 }