Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 2 of 2 total |
Freeing controls via Controls[] array throws error |
Thu, May 24 2012 12:22 AM | Permanent Link |
Rick | Tim
I have a panel (Panel1) on the main form along with two buttons. The first button dynamically adds child panels to Panel1. The second button removes (frees) the child panels from Panel1. The OnClick definitions are as follows: procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin for i:=1 to 10 do with TPanel.Create(Panel1) do begin Width:=100; Height:=100; Top:=Round(Random()*Panel1.ClientHeight); Left:=Round(Random()*Panel1.ClientWidth); ShowShadow:=True; end; end; procedure TForm1.Button2Click(Sender: TObject); begin while Panel1.ControlCount<>0 do TPanel(Panel1.Controls[0]).Free; end; Button1 works correctly. Clicking Button2 however throws the following errors: IE8: Cannot assign to a function result Line: 12873 Firefox: Invalid assignment left-hand side Line: 12873 If the OnClick for Button2 is changed to the following then the child panel removal works correctly. procedure TForm1.Button2Click(Sender: TObject); var p: TPanel; begin while Panel1.ControlCount<>0 do begin p:=TPanel(Panel1.Controls[0]); p.Free; end; end; Should it be possible to free an object directly from the Controls[] array? -- Rick |
Fri, May 25 2012 4:15 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Rick,
<< Should it be possible to free an object directly from the Controls[] array? >> No, I'll make sure that this is fixed. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, September 9, 2024 at 03:13 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |