private void PerformWmPaintWmPrintClient(ref Message m, bool isPaintMessage)
        {
            Paintstruct paintstruct1 = new Paintstruct();
            IntPtr      ptr1         = (isPaintMessage ? User32.BeginPaint(m.HWnd, ref paintstruct1) : m.WParam);
            RectStruct  rect1        = new RectStruct();

            User32.GetWindowRect(Handle, ref rect1);
            Rectangle rectangle1 = new Rectangle(0, 0, rect1.right - rect1.left, rect1.bottom - rect1.top);

            using (Graphics graphics1 = Graphics.FromHdc(ptr1))
            {
                Bitmap bitmap1 = new Bitmap(rectangle1.Width, rectangle1.Height);
                using (Graphics graphics2 = Graphics.FromImage(bitmap1))
                    PerformPaint(new PaintEventArgs(graphics2, rectangle1));
                graphics1.DrawImageUnscaled(bitmap1, 0, 0);
            }
            if (isPaintMessage)
            {
                User32.EndPaint(m.HWnd, ref paintstruct1);
            }
        }
 internal static extern bool EndPaint(IntPtr hWnd, ref Paintstruct ps);
 internal static extern IntPtr BeginPaint(IntPtr hWnd, ref Paintstruct ps);
 internal static extern bool EndPaint(IntPtr hWnd, ref Paintstruct ps);
 internal static extern IntPtr BeginPaint(IntPtr hWnd, ref Paintstruct ps);
 private void PerformWmPaintWmPrintClient(ref Message m, bool isPaintMessage)
 {
     Paintstruct paintstruct1 = new Paintstruct();
       IntPtr ptr1 = (isPaintMessage ? User32.BeginPaint(m.HWnd, ref paintstruct1) : m.WParam);
       RectStruct rect1 = new RectStruct();
       User32.GetWindowRect(Handle, ref rect1);
       Rectangle rectangle1 = new Rectangle(0, 0, rect1.right - rect1.left, rect1.bottom - rect1.top);
       using (Graphics graphics1 = Graphics.FromHdc(ptr1))
       {
     Bitmap bitmap1 = new Bitmap(rectangle1.Width, rectangle1.Height);
     using (Graphics graphics2 = Graphics.FromImage(bitmap1))
       PerformPaint(new PaintEventArgs(graphics2, rectangle1));
     graphics1.DrawImageUnscaled(bitmap1, 0, 0);
       }
       if (isPaintMessage)
     User32.EndPaint(m.HWnd, ref paintstruct1);
 }