Recently, I was facing issue with third party Image Viewer to apply multiple operations before redrawing of images.
Third-party control was not allowing to suspend and resume painting of images inherently. After searching for various solutions, I found a solution that can be achieved using windows message “WM_SETREDRAW“ from an application to Windows to allow changes in that control to be redrawn or to prevent changes in that control from being redrawn.
public class UIDrawController
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
private const int WM_SETREDRAW = 11;
public static void SuspendDrawing(Control ctrl)
SendMessage(ctrl.Handle, WM_SETREDRAW, false, 0);
public static void ResumeDrawing(Control ctrl)
SendMessage(ctrl.Handle, WM_SETREDRAW, true, 0);
public ImageViewer : UserControl
public void LoadDocument(string filename)