Freeze GUI

  • Thread starter Thread starter schaf
  • Start date Start date
S

schaf

Hi NG!
I have a panel which acts as a container for different usercontrols.
Depending on the current state the corresponding usercontrol is
displayed. If I change the state, I remove the current usercontrol from
the panel and add the new one.
During initializing the new usercontrol the panel shows some textbox
component boarders of the removed usercontrol, which does not look very
nice. How can I freez the GUI or the panel and only call a repaint
after the initializing process ?
I tried with Suspend- and ResumeLayout, but this does not work.
Thanks and regards
Marcel
 
Hi,
Have you tried the Invalidate() or Refresh() methods of your panel?
You could implement the swapping functionality inside your usercontrol
so these are called automatically when the swap is made. I would still
use SuspendLayout() and ResumeLayout() aswell...

Cheers,
James.
 
Hi pigeonrandle:
Have you tried the Invalidate() or Refresh() methods of your panel?
Does invalidate not force the redrawing ? During the initializing time
my panel looks not nice. So I would like to keep the old usercontrol UI
freezed on the screen during this time. after the new usercontrol is
loaded and initialized i would like to show this one.
You could implement the swapping functionality inside your usercontrol
so these are called automatically when the swap is made.
I have it. With each state transition my new usercontrol is
automatically loaded. Or what do you mean?

Thanks
 
In some "extreme" cases I use the Win32 "LockWindowUpdate()"...
(! You can Lock only one control at a time. Locking an second control will
Unlock the previous locked one)


public class TWinFct
{
[DllImport("user32")]
private static extern int LockWindowUpdate(IntPtr hwndLock);


public static int LockControlUpdate(Control AControl)
{
return LockWindowUpdate(AControl.Handle);
}

public static int UnLockControlUpdate()
{
return LockWindowUpdate(IntPtr.Zero);
}
}



usage :

{
//Lock Control update
TWinFct.LockControlUpdate(MyControl)
//.... do things
//Unlock Control update
TWinFct.UnLockControlUpdate()
}


Steph.
 
schaf said:
Hi pigeonrandle:

Does invalidate not force the redrawing ? During the initializing time
my panel looks not nice. So I would like to keep the old usercontrol UI
freezed on the screen during this time. after the new usercontrol is
loaded and initialized i would like to show this one.

I have it. With each state transition my new usercontrol is
automatically loaded. Or what do you mean?

My first question would be: what is the program doing while the UI is
frozen? Perhaps there is some initialization code in your user control
that is taking a lot of time?

If that code is in the constructor then it's easy: just instantiate the
new user control before you start removing the old user control.

If that code is in the Load method (which is where it should be), then
it's a little more difficult: you have to use a background thread to do
the work, so that the UI can update itself.

So... what is going on in the initialization stages of your user
control that is taking so much time?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top