Link to home
Start Free TrialLog in
Avatar of tdk_man

asked on

Resizing Form With Multiple TPanels Causing Major Flicker

I know this topic has been brought up many times before, but none of my searches have resulted in finding a definitive answer anywhere.

My main form has a menu bar, multiple buttons on a panel running across the top, Panels, Splitters, TreeViews, a Header Control and a StatusBar.

The splitters allow me to resize the panels which have other components on them (primarily TreeViews) in a layout like Outlook Express.

Resizing is OK, but as soon as I resize the main form, I get MAJOR flickering and flashing bands on all the main panels, header control and status bar.

Oddly enough, the menu bar, the panel running across the top of the form with all my buttons on and the two TreeView panels are rock steady - not a hint of flickering.

Double buffering of the main form and panels has no effect whatsoever and LockWindowUpdate seems to work quite well, but all the icons on my desktop flash like there's no tomorrow!

Anyone help please?

Avatar of zion29

A simple test I did:

procedure TForm1.FormCreate(Sender: TObject);

It does reduce the flicker. :)
Avatar of tdk_man


I think the possible problem is that I have a total of 7 panels and two splitters (which resize three of them).

Setting Double Buffering on them all as I said has no effect.

With just two controls as used in your test there probably isn't a problem.

I'm trying to create an app which works the way Outlook Express does with multiple sizeable frames.

Is there a better component than Panel to use I wonder?

I've used multiple nested panels in plenty of applications, without any significant flicker. Sounds to me it is something else than the panels causing it.

How about you View form as Text and.. paste or link to it somewhere. That would make it alot easier to figure out I guess :)
The usual way to stop panels from flickering is to call the BeginUpdate method of the TCollection component which represents them. The flickering is usually caused by the controls redrawing themselves as soon as a property changes.

It is a shame that TForm does not use a TCollection to hold all the controls dropped onto it (which would save the mess of declarations which the object inspector does to the form's unit!). I don't know how exactly TCollection stops the redrawing since it is not derived from TWinControl. But in any event the use of the method should help out somewhat.
Avatar of Lesko987

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial