PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: JR Heathcote on February 05, 2006, 05:22:36 PM

Title: Resizing Controls
Post by: JR Heathcote on February 05, 2006, 05:22:36 PM
I have a form where the controls are resized/relocated as the form is resized.  The resize code is working OK, but what tricks does one employ to reduce or eliminate flicker when controls are moved?

TIA
Title: Resizing Controls
Post by: Roger Garstang on February 06, 2006, 04:08:40 AM
Turn off the Redraw Class Styles, only paint areas once (The normal Erase Background then draw text/control causes the area occupied by it to be drawn twice- once on erase and once on draw...try to find ways to draw what is needed in one operation or compose "off-screen" and transfer finish product [Double Buffer]).  Along with painting once...I've found in some of my resize/move code that pieces can get in the way of each other or move wrong/noticable, so use DeferWindowPos and its related Begin/End Functions.  This then does all the drawing in the background and redraws the window in one command when done.
Title: Resizing Controls
Post by: JR Heathcote on February 06, 2006, 10:00:19 AM
Thanks, will give it a try.
Title: Resizing Controls
Post by: TechSupport on February 06, 2006, 01:39:15 PM
I think that DeferWindowPos is the best general purpose solution for resizing flicker. Like Roger said, the actual redraw only happens once which will look much more pleasing visually.

There are some controls that will always flicker regardless of what you do. For example, I have yet to find a way to prevent a Tab Control from flickering when it is resized. Nothing short of doing a complete ownerdraw  implementation seems to work (and I have searched a lot on google for equivalent ideas in C/C++ or VisualBasic - no luck).
Title: Resizing Controls
Post by: TechSupport on February 15, 2006, 11:30:21 AM
Oh, here is one that I forgot.... Make sure that the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles are enabled for your Form (I don't think they are by default). This will clip the redraw so the area under your controls are not drawn and then the control drawn on top of it (causing flicker).
Title: Resizing Controls
Post by: Roger Garstang on February 15, 2006, 07:13:58 PM
Sometimes WS_CLIPSIBLINGS gives problems in XP with Frames.  Usually when the Balloon Tips popup to do with letters in a number textbox or caps lock on in a password box, etc.  Frames sometimes dissappear.