Board index » cppbuilder » TPanel strange behavior during repaint

TPanel strange behavior during repaint

Hi all.

I have 400 TPanels on a form. They're created at run-time
but I notice the same effect though I put them at
design-time, so it seems it doesn't matter. The problem is
that when my form (and so the panels) has to be redrawn
(e.g. if you open another window over my form and then close
it) I see a very slow and strange repaint of the panels: it
seems they're deleted and then re-created. Furthermore, I
can see the same effect at design-time (in the IDE) by
showing and hiding my form with F12. On fast PCs it's just a
bad refresh, but on slow PCs this refresh takes more than 3
seconds and it's not acceptable.

I'd like to know why this happens and a solution or
workaround. I've done some tests with other components as
well and the strange refresh persists.

Thanks in advance,

Steve.

 

Re:TPanel strange behavior during repaint


Quote
"Steve" <steve_alettoA...@SPAMhotmail.com> wrote in message

news:3e967d2e@newsgroups.borland.com...

Quote
> I have 400 TPanels on a form.

That is WAY too many to have on a single form at the same time.  I'm
guessing you don't realize just how many resources that takes up.  TPanel is
a TWinControl descendant.  Thus it is a windows control.  Every windows
control has a HWND window, which in turn has a group of resources associated
with it - a window, fonts, pens, brushes, etc.  Multiple that amount by 400
and it becomes very large.  It's no wonder your form is so slow, the OS is
doing an extremely large amount of processing to manage all of those
resources for you.  You seriously need to re-think your form's design to
slim it down, move controls into separate windows, etc.

Quote
> it seems they're deleted and then re-created.

Not deleted - simply drawn over with a a blank slate first for the
background, and then the actual contents on top of it.

Gambit

Re:TPanel strange behavior during repaint


Quote
> > I have 400 TPanels on a form.

> That is WAY too many to have on a single form at the same

time.

Thank you Remy, but I need some further clarifications.
I've tried with 400 TLabels as well, but with the same
result. I know they take a lot of resources, so I don't
complain if the refresh is slow. But if I make a similar
form in another IDE (i.e. VisualBasic) I don't notice such
problem. That's why I'm asking. It seems BCB handles objects
in a different way OR something wrong is present in my
application (strange since the problem is present at
design-time, too). So I'd like to know why this happens
(what's the difference between BCB and VB in this case) and
a possible solution or improvement.

Thanks in advance,

Steve.

Other Threads