Suppressing paint event on forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I need a way to disable form re-painting until I am done enabling and disabling all controls on the form. The problem I am having is that we have multiple objects (a security component and the specific business UI object) that will indepently enable and disable controls based on a user's role and the business rules of an object (for example, the user may have the rights to enter interview results, but if the applicant hasn't yet been invited, the Interview Results control will be disabled). We are using an Edit button on all our forms, so when that button is pressed, all the controls flicker on and off as the different objects run through their routines. What we want to do then is suspend form painting at the start of the various evaluations, let all the objects enable and disable the various controls, and at the end allow the form to paint the final state of all the controls. We looked into SuspendLayout, but it doesn't seem to cover our problem, plus it is too granular, applying only to the control it is called on. We would like to tell the form to suspend all re-drawing until we give the signal

Any help would be appreciated

Thanks

-Tod
 
Hi tpenland,

The best is I believe is not to update the controls status during
evaluation.

Even if you could stop the form's repainting (as a matter of fact there is
no managed solution, but you could do that sending WM_SETREDRAW to the
form's window) all controls on the form will keep changing their status
because they are separate windows.

--

Stoitcho Goutsev (100) [C# MVP]


tpenland said:
Hello,

I need a way to disable form re-painting until I am done enabling and
disabling all controls on the form. The problem I am having is that we have
multiple objects (a security component and the specific business UI object)
that will indepently enable and disable controls based on a user's role and
the business rules of an object (for example, the user may have the rights
to enter interview results, but if the applicant hasn't yet been invited,
the Interview Results control will be disabled). We are using an Edit
button on all our forms, so when that button is pressed, all the controls
flicker on and off as the different objects run through their routines.
What we want to do then is suspend form painting at the start of the various
evaluations, let all the objects enable and disable the various controls,
and at the end allow the form to paint the final state of all the controls.
We looked into SuspendLayout, but it doesn't seem to cover our problem, plus
it is too granular, applying only to the control it is called on. We would
like to tell the form to suspend all re-drawing until we give the signal.
 
On your suggesion Travis, I've been playing with the form's OnPaint handler. However, it seems that preventing the form's OnPaint from firing doesn't actually affect the controls on the form. I'm guessing that each control handles its own painting, so preventing the form from painting is affecting only display issues regarding the form control itself, but not any control that it contains. I'm going to look into somehow intercepting each control's OnPaint handler...although how I'll do that in a generic manner that fits into our current framework I don't yet know

Thanks for the help

-Todd
 
Back
Top