On achieving super smooth refreshes...

  • Thread starter Thread starter R3al1ty
  • Start date Start date
R

R3al1ty

Hi folks, I have a small modal form in front of a big form. How do i
cleanly hide the small modal form? Currently, when i do
smallForm.Hide(), the bigForm area that was under the smallForm
refreshes in bits and pieces.


mainForm.Show()

smallForm.ShowDialog()

smallForm.Hide()

// ugly refreshing


Is there a combination of either ControlStyles settings or
Refresh/Invalidate/SuspendLayout etc that can be inserted into the
above order that can give a smooth Hide(). I just want it to dissapear
cleanly.

Thanks!
 
R3al1ty,

How busy is the form under the dialog?
If the form content is mostly drawing done by the form itself (not using
controls) you may consider double buffer the form and it might help, but
this doesn't help with forms with a lot of controls.

There is one trick that I'd suggest to try. Set the form's opacity to some
value closer to 1.0 (100%), but still less than 1.0 e.g 0.99 (99%). Doing
that the form will become layered window. These windows are handled specialy
by the OS that is the OS draws the whole window on an image and then blends
the image with the rest of the windows on the desktop applying specified
transparency. Layered windows receive less request for repainting. This is
kind of double buffering of the whole content of the form (including the
controls). In .NET 1.x when one changes the opacity to something less than
100% the forms became a layered window then if one changes the opacity back
to 100% the form somehow was forgetting to remove the layering and we had
opaque form with nice double buffering. Unfortunately (for this case) in 2.0
this has been fixed so you need to keep the opacity less than 100% in order
this to work.
Anyhow, if you have busy form with a lot of control, which is fairly
static - means there is not controls moving around or some kind of animation
going on this may help. Give it a shot.
 
Back
Top