C# Stop / Suspend painting for a control.

Original post from stack overflow: How do I suspend painting for a control and its children?
The code below is used to suspend painting for control to speed up processing.


using System.Runtime.InteropServices;

class DrawingControl
{
    [DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, 
                                         bool wParam, Int32 lParam);
 
    private const int WM_SETREDRAW = 11;
 
    public static void SuspendDrawing(Control parent)
    {
        SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
    }
 
    public static void ResumeDrawing(Control parent)
    {
        SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
        parent.Refresh();
    }
}

Popular posts from this blog

(AGauge) WinForms Gauge Control - Discontinued

WinForms Controls

C# DSP Simulation - DSP Lab