Exemple #1
0
        private void PaintWithDoubleBuffer(ref Message m)
        {
            using (Graphics g = Graphics.FromImage(myDoubleBufferBitmap))
            {
                // TODO: use correct background brush for non-standard background
                g.FillRectangle(SystemBrushes.Window, 0, 0, ClientSize.Width, ClientSize.Height);
                IntPtr hdc = g.GetHdc();
                // the treeview ignores the drawing options anyway
                Win32Declarations.SendMessage(Handle, Win32Declarations.WM_PRINTCLIENT, hdc, IntPtr.Zero);
                g.ReleaseHdc(hdc);
            }
            PAINTSTRUCT ps = new PAINTSTRUCT();

            Win32Declarations.BeginPaint(m.HWnd, ref ps);
            using (Graphics g = Graphics.FromHdc(ps.hdc))
            {
                g.DrawImage(myDoubleBufferBitmap, 0, 0);
            }
            Win32Declarations.EndPaint(m.HWnd, ref ps);
        }