views:

237

answers:

1

I have a screen with say 20 controls on it. I want to show all twenty, then hide only the ones that don't relate to what I'm working on.

psudoCode.
for each element 
    show element 

for each element in hide list
    hide element.

My problem is that between the loops the screen paints. It looks very ugly.
I know I've seen this done but for the life of me I can't find that code, or even remember what app I'd seen that code in..

Does anyone know how to suspend the paint for a bit?

+2  A: 

As someone suggested to me not long ago, use CWnd::SetRedraw

wnd.SetRedraw(FALSE)
... // do your stuff with elements
wnd.SetRedraw(TRUE)
Peter
ah, yeah you are right. too long since i had used MFC :)
Johannes Schaub - litb
That would have to be called for each control being shown / hidden.
Shog9
Are you sure that has to be called for each control?
baash05
If you hide the window it should not take part in the paint process unless something else is invalidating the window or sending it WM_Paint messages.
Aaron Fischer
I take that back - it appears that, when called on the dialog, SetRedraw(FALSE) will prevent all drawing of children until SetRedraw(TRUE) is called.
Shog9
Yes. that is common. In wx this is called freeze/thaw, and it's recursive for children too
Johannes Schaub - litb