Recent

Author Topic: create component in runtime ... limit ?  (Read 5850 times)

Maziar123

  • Newbie
  • Posts: 3
create component in runtime ... limit ?
« on: November 12, 2010, 04:00:03 pm »
Hi

i try below code :

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
   i : Integer;
   t : DWord;
   P : TPanel;
   LastPanel : TPanel;
begin
     t := GetTickCount;
     LastPanel := Panel1;;
     for i := 0 to 20 do begin
         P := TPanel.Create(Self);
         P.Parent := LastPanel;
         p.Align:=  alClient;
         LastPanel := p;
     end;
     ShowMessage(inttostr(GetTickCount - t));
end;


i get error if for loop value (in up code is 20) is over 70  for 20 work true! why ?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: create component in runtime ... limit ?
« Reply #1 on: November 12, 2010, 04:26:44 pm »
Windows API AFAIK doesn't limit it, so the only limit is your memory. What's the error message?

Maziar123

  • Newbie
  • Posts: 3
Re: create component in runtime ... limit ?
« Reply #2 on: November 12, 2010, 05:40:54 pm »
error 87 : parameter is not correct ! seven 64 bit using lazarus 64bit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki

Maziar123

  • Newbie
  • Posts: 3
Re: create component in runtime ... limit ?
« Reply #4 on: November 12, 2010, 06:26:36 pm »
yes ....no more understand

BUT why same code work in delphi ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki
Re: create component in runtime ... limit ?
« Reply #5 on: November 12, 2010, 06:58:08 pm »
It doesn't work in Delphi.

I just tested "Turbo Delphi 2006"

same error

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: create component in runtime ... limit ?
« Reply #6 on: November 12, 2010, 07:15:06 pm »
It might be due to random memory layout.

Not all code that works is good.

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: create component in runtime ... limit ?
« Reply #7 on: November 13, 2010, 02:27:44 pm »
i can confirm that there is a limit to how deep you can nest the controls (varies among windows versions) but nobody ever cared about it.

is there a remotely sane reason to make a 50 level deep component tree?

write the whole thing off as a discovery of interesting fact. in a normal layout, lazarus won't mind you creating thousands of panels.

 

TinyPortal © 2005-2018