Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Suppressing paint


I have an mdi form with many dockpanels. Is there some way I can do something with the main form so that none of the child windows will be painted? Something like .BeginUpdate and .EndUpdate that is used for ListView and TreeView. The problem is that I´m reading the child window locations from a file and I always see a flicker because first they appear in a default location and then i move them to the saved location. I have no way to hide them before I add them because they are created using a method .AddPanel in a third party component and that will always show them first in the default position.


Thursday, May 5, 2005

Here's how it is done in Win32..

Don't know about the analagous function in .NET.

Michael H. Pryor (fogcreek)
Fog Creek Software
Thursday, May 5, 2005


Thursday, May 5, 2005

This might help

Charles Reich
Thursday, May 5, 2005

Something like this will work by dropping down to Win32 level (which is *still* there).  (NOTE: Assumes that you've inherited from the control you want to stop painting on).

(NOTE: EndUpdate invalidates the parent -- if you only need to invalidate the control, subsitute "this" for "Parent").

    private const int WM_SETREDRAW = 11;  // 0x000B
    static extern bool SendMessage(IntPtr hWnd, Int32 msg, Int32 wParam, Int32 lParam);
      public void BeginUpdate()
        SendMessage( this.Handle, WM_SETREDRAW, 0, 0);

      public void EndUpdate()
        SendMessage( this.Handle, WM_SETREDRAW, 1, 0);

Thursday, May 5, 2005

You should use LockWindowUpdate. It will stop all painting of the window until you unlock it.

//API Declaration
[System.Runtime.InteropServices.DllImport("user32.dll")] static extern Int32 LockWindowUpdate(Int32hwndLock);

private void SomeFunction()
    //Lock the Window
    // Do stuff
    //Unlock the Window    

Monday, May 9, 2005

I don't LockWindowUpdate is what you want here. As per , LockWindowUpdate is not made for this. WM_SETREDRAW on  the other hand is.

Mike L.
Thursday, June 9, 2005

*  Recent Topics

*  Fog Creek Home