Avatar of tdk_man
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?

TDK_Man
Delphi

Avatar of undefined
Last Comment
Lesko987

8/22/2022 - Mon
zion29

A simple test I did:

procedure TForm1.FormCreate(Sender: TObject);
begin
  HeaderControl1.DoubleBuffered:=True;
  StatusBar1.DoubleBuffered:=True;
end;

It does reduce the flicker. :)
tdk_man

ASKER
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?

TDK_Man
zion29

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 :)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
BigRat

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.
ASKER CERTIFIED SOLUTION
Lesko987

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.