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); }
public virtual void SetWindowRegion(GDIRegion aRegion) { RegionCombineType retValue = (RegionCombineType)User32.SetWindowRgn(Handle, aRegion.DangerousGetHandle(), true); }