|
32.29 Is there a way to halt a screen from painting until all the controls on the form are initialized?
|
Shawn Burke responded to this question in a posting on microsoft.public.dotnet.framework.windowsforms newsgroup.
There is not currently a way to do this built into the framework, but WM_SETREDRAW will do what you're looking for. It can't be called recursively, so here's code for a property you can add to your form to handle it. A VB sample is also available.
|
private const int WM_SETREDRAW = 0xB;
|
private static extern bool SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
|
private bool FreezePainting
|
get { return paintFrozen > 0; }
|
if (value && IsHandleCreated && this.Visible)
|
SendMessage(Handle, WM_SETREDRAW, 0, 0);
|
SendMessage(Handle, WM_SETREDRAW, 1, 0);
|
|
|
|