You probably know the annoying flickering effect windows suffer from when they are resized. I have a window with a pattern brush as background, with a toolbar & statusbar. When I resize the main window, the toolbar and statusbar flicker continously. Is there a solution to this problem? Is it possible to make a backbuffer for controls too (i.e. draw the backrground, toolbar and statusbar on a backbuffer first, then draw it to the actual window)? Thomas
Posted on 2001-04-22 09:35:00 by Thomas
Thomas, There are a few tricks to reduce flickering, remove the CS_HREDRAW and CS_VREDRAW redraw styles from the WNDCLASSEX as it force screen upgrade on either vertical or horizontal redraw. If you can cover the entire client area with controls, make the background brush a HOLLOW_BRUSH as this further reduces the flicker. Flickering is basically 2 or more windows updating their display at the same time so if you can prevent the one under the control from updating, it solves a lot of the problem. Regards, hutch@pbq.com.au
Posted on 2001-04-22 10:18:00 by hutch--
Removing the CS_HREDRAW and CS_HVEDRAW styles does not help very much, and I can't fill the window with controls. The flickering problem is caused by drawing the background and the toolbar at the same time, when I handle WM_ERASEBKGND and paint the background manually, and skip the region where the toolbar is, it works perfectly. The problem is that the toolbar can move and resize and that there are more controls that can move. I tried using regions (first filling a region with the whole update screen, removing the regions controls are shown, then filling the region) but I find it very hard to work well with regions (there's no such thing as 'SetRegion' or 'JustCreateAnUndefinedRegion' :)). But wouldn't it be possible to make windows draw the controls on a backbuffer instead of the window itself? That would solve all problems... Thomas
Posted on 2001-04-22 13:38:00 by Thomas
Thomas, Setting the background brush to HOLOW_BRUSH will still do the job if you fill the client area with another window, it at least prevents the main window and the toolbar/status bar from interacting on change. Have a look at the WM_SETREDRAW message either side of a control change as one way of reducing the interaction of each control with the window below it. Regards, hutch@pbq.com.au
Posted on 2001-04-22 19:42:00 by hutch--
I found a working method: I registered another class which is just a simple window with a background brush (a bitmap). I add this control to the main window, filling the whole window, and always at the lowest Z-order. Then all controls are on top of that window. When every control has the WS_CLIPSIBBLINGS (and WS_CLIPCHILDREN if needed) style, windows prevents controls from drawing at the same piece of the window at the same time. The new window class was nessecairy because WS_CLIPSIBLINGS and WS_CLIPCHILDREN do not work with the main window. My window is now almost flicker-free, only a little border of the toolbar and the main menu, but not much. Thanks for your help, Thomas
Posted on 2001-04-23 10:46:00 by Thomas