Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread Performance when creating many controls dynamically
Sun, May 20 2012 9:04 AMPermanent Link

Rick

Hi Tim.

I have a panel on a form and need to dynamically create a large number of
sub-panels which will be parented to the main panel.

In Firefox this seems to run fairly quickly but is quite slow in IE8.

Is there any BeginUpdate/EndUpdate type capability in EWB which allows a
sub-document to be created dynamically (e.g. consisting of many panels) and
then inserted into the DOM in one operation?

It appears that the individual creates are quite slow. I've even tried by
specifying nil in the create call which is very fast but then setting the
parent property causes the slow down.

The following code is an example of what I'm trying to do:

procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i:=1 to 50 do
begin
//  with TPanel.Create(nil) do
 with TPanel.Create(Panel1) do
  begin
//    Parent:=Panel1;
   ShowCaption:=False;
   Width:=50;
   Height:=50;
   Top:=Round(Random()*Panel1.ClientHeight);
   Left:=Round(Random()*Panel1.ClientWidth);
  end;
end;
end;

I know that the IE Javascript engine isn't brilliant but even Firefox tends
to slow down as the number of sub-panels increases.

Thanks.

--
Rick

Sun, May 20 2012 5:37 PMPermanent Link

Leslie

Rick,

I have the exact same problem. IE8 uses only one core. while newer browsers seem to benifit from multi core CPUs  and that makes a difference. Anyhow this is surprizingly slow. An optimized DBCtrlPanel like control would be very useful. Populating  a dataset from JSON is also quite slow with a few hundred records. I do not really know what can be realisticly expected here speedwise. Hope Tim can shed some light on it. Smile

Cheers,
Leslie
Sun, May 20 2012 6:08 PMPermanent Link

Leslie

Rick,

One more thing: instead of using panels I have created  a class which is not a container.  All controls which would normally be placed within a container are properites of this class but children of the same parent.(The parent of  the original panels.)  This is still slow if you create many of them, but having all controls in a single container is much faster than with multi level containers.

Cheers,
Leslie
Mon, May 21 2012 12:21 AMPermanent Link

Rick

<Leslie> wrote in message
news:3E18F2C5-5325-4D81-902B-8C71272FFE8E@news.elevatesoft.com...
>
> One more thing: instead of using panels I have created  a class which is
> not a container.  All controls which would normally be placed within a
> container are properites of this class but children of the same
> parent.(The parent of  the original panels.)  This is still slow if you
> create many of them, but having all controls in a single container is much
> faster than with multi level containers.
>
>

Thanks Leslie.

Problem seems to be that as soon as you set the parent of the child panel
either via create or specifically the performance issue occurs.

I tried setting the parent of the container panel to nil and then created
the child panels with the container panel as the parent. Much, much faster.
Unfortunately setting the parent of the container panel back to the form
displayed corrupted child panels.

Here's an example:

procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
Panel1.Parent:=nil;
for i:=1 to 50 do
begin
 with TPanel.Create(Panel1) do
  begin
   Width:=50;
   Height:=50;
   Top:=Round(Random()*Panel1.ClientHeight);
   Left:=Round(Random()*Panel1.ClientWidth);
  end;
end;
Panel1.Parent:=Form1.
end;

This works like BeginUpdate/EndUpdate but the contents of the container
panel (Panel1) are corrupted. Pity.

--
Rick

Mon, May 21 2012 12:00 PMPermanent Link

Leslie

Rick,

Your Panel1 is a TContainerControl descendent in  my code. If it has a constructor, assigning the parent only after the subcontols have been created  does not work. But if it has NO constructor it does work and the speed is better. Smile

Cheers,
Leslie
Mon, May 21 2012 7:39 PMPermanent Link

Leslie

TCheckBox created within a parent without  a parent are not working . Not expecting clicks, no check marks,  The rectangle is not highlited when mouse is over. It is highlited when it is over the the caption.

Cheers,
Leslie
Mon, May 21 2012 7:47 PMPermanent Link

Leslie

Leslie wrote:

TCheckBox created within a parent without  a parent are not working . Not expecting clicks, no check marks,  The rectangle is not highlited when mouse is over. It is highlited when it is over the the caption.


I meant: Not accepting clicks.

Cheers,
Leslie
Mon, May 21 2012 7:48 PMPermanent Link

Leslie

Even if parent is not cleared before creating subcontrols in IE clicking on the CheckBox caption is not accepted

Cheers,
Leslie
Mon, May 21 2012 9:03 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

Please send me an example project that shows what you're trying to do.  I'll
check it out and see what the issue is.  I haven't done a lot of work on
un-parented controls, so it doesn't surprise me that it doesn't work
properly.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, May 21 2012 9:05 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Leslie,

<< TCheckBox created within a parent without  a parent are not working . Not
expecting clicks, no check marks,  The rectangle is not highlited when mouse
is over. It is highlited when it is over the the caption. >>

It works fine here in IE8.  Are you using the most current build ?

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page »
Jump to Page:  1 2
Image