private void PerformWmPaint(ref Message m) { PAINTSTRUCT ps = new PAINTSTRUCT(); Rectangle rectClient = ClientRectangle; IntPtr hDC = User32.BeginPaint(m.HWnd, ref ps); using (Graphics g = Graphics.FromHdc(hDC)) { using (Bitmap bitmap1 = new Bitmap(rectClient.Width, rectClient.Height)) { using (Graphics graphics2 = Graphics.FromImage(bitmap1)) { OnPaint(new PaintEventArgs(graphics2, rectClient)); } g.DrawImageUnscaled(bitmap1, 0, 0); } } User32.EndPaint(m.HWnd, ref ps); }
internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
internal static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps);