Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At my previous job we struggled with getting our rich UI app to paint instantly and smoothly. We were using standard .Net controls, custom controls and devexpress controls.</p> <p>After a lot of googling and reflector usage I came across the WM_SETREDRAW win32 message. This really stops controls drawing whilst you update them and can be applied, IIRC to the parent/containing panel.</p> <p>This is a very very simple class demonstrating how to use this message:</p> <pre class="lang-cs prettyprint-override"><code>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(); } } </code></pre> <p>There are fuller discussions on this - google for C# and WM_SETREDRAW, e.g.</p> <p><a href="https://web.archive.org/web/20160324214157/http://blog.bee-eee.com/2008/04/18/c-getting-rid-of-the-jitter/" rel="noreferrer">C# Jitter</a></p> <p><a href="http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=52" rel="noreferrer">Suspending Layouts</a></p> <p>And to whom it may concern, this is similar example in VB:</p> <pre class="lang-vb prettyprint-override"><code>Public Module Extensions &lt;DllImport("user32.dll")&gt; Private Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Boolean, ByVal lParam As IntPtr) As Integer End Function Private Const WM_SETREDRAW As Integer = 11 ' Extension methods for Control &lt;Extension()&gt; Public Sub ResumeDrawing(ByVal Target As Control, ByVal Redraw As Boolean) SendMessage(Target.Handle, WM_SETREDRAW, True, 0) If Redraw Then Target.Refresh() End If End Sub &lt;Extension()&gt; Public Sub SuspendDrawing(ByVal Target As Control) SendMessage(Target.Handle, WM_SETREDRAW, False, 0) End Sub &lt;Extension()&gt; Public Sub ResumeDrawing(ByVal Target As Control) ResumeDrawing(Target, True) End Sub End Module </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload